1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Question] PHP, Wordpress, headers and posts.

Discussion in 'BlackHat Lounge' started by royserpa, Nov 21, 2013.

  1. royserpa

    royserpa Jr. VIP Jr. VIP Premium Member

    Joined:
    Sep 28, 2011
    Messages:
    4,645
    Likes Received:
    3,492
    Gender:
    Male
    Occupation:
    Negative Options aka Rebills!
    Location:
    Royserpa
    Home Page:
    Hello guys,

    As many of you know, my 2000th post will be the Viral Script Plugin for Wordpress :cool:

    But, the only thing left to do is this. This is the only thing left to make the plugin workable!

    Ok, so the thing is this:

    On the header of the theme (not the <head></head> tags), I need to declare a variable in php that will be used on the header of the theme AND on the posts.

    So I declared the variable this way on the header.php:

    PHP:
    <?php global $var$var "some value I need"?>
    But when I go to any post and call the $var using:

    PHP:
    <?php echo $var?>
    The variable appears empty, even after I called it global on the header.php of the theme.

    So the thing is, how on Earth can I call the variable on any post I want?

    I probably must be missing something here! Any comments are appreciated! :)


    Ohh, and for the sake of trying this, this a small test I did:

    On the header.php of the theme I entered:

    PHP:
    <?php global $var$var "Hopefully this works!"?>
    Then on any post, I call the $var using:

    PHP:
    <?php echo "What's the value of var? Answer is: $var"?>
    And of course, only "What's the value of var? Answer is: " prints...

    Probably there's some kind of minor mistake I'm making here :)D), so any help or comment is greatly appreciated!
     
  2. cnick79

    cnick79 Jr. VIP Jr. VIP

    Joined:
    Jun 10, 2010
    Messages:
    653
    Likes Received:
    341
    Location:
    Google's SandBox
    Do you have global $var defined on your post template file like this?
    PHP:
    <?php global $var; echo "What's the value of var? Answer is: $var";?>
     
    • Thanks Thanks x 1
  3. royserpa

    royserpa Jr. VIP Jr. VIP Premium Member

    Joined:
    Sep 28, 2011
    Messages:
    4,645
    Likes Received:
    3,492
    Gender:
    Male
    Occupation:
    Negative Options aka Rebills!
    Location:
    Royserpa
    Home Page:

    OMFG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    DUDEE!!!!!!!!!!!

    Thanks soooooooooooooo muuuuuuuuuuuuuuuuuuuuuuuch!!!!!!!!!!!!!!!!!!!

    THAT DID THE TRICK MAN!!!!

    Hahahahahahhahaha

    I knew it was some silly mistake!!!!

    I will give credits to you for the help man!!!

    Wish I could +rep you man!! :D:D:D:D:D:D