PHP - Wordpress - Global Variables

3 replies
Ok,

I want to set in the functions.php that $X = Y so throughout the rest of my theme I can simply echo $X

Also, I have a lot of variables that are set through the themes option page so it needs to work for multiple variables.

How do I do this coolness?
#global #php #variables #wordpress
  • Profile picture of the author jasonmorgan
    OK, solved this little issue.

    Apparently wordpress doesn't carry over global variables into the header, footer, sidebar etc... which is why I was running into problems. I was testing out my code in the header. Silly me.
    Signature

    I'm all about that bass.

    {{ DiscussionBoard.errors[3483648].message }}
  • Profile picture of the author andreasnrb
    The globals variables is not WordPress behavior its PHPs default behavior.
    If you are doing theme options etc Chip Bennet has a great tutorial on the subject.
    Incorporating the Settings API in WordPress Themes » cb.blog
    Do as he writes and your theme will be better than most.

    But you should avoid globals and try to move over to PHP 5.
    {{ DiscussionBoard.errors[3485885].message }}
  • Profile picture of the author voitenkos
    How did you solve it though?
    {{ DiscussionBoard.errors[3556195].message }}

Trending Topics