PHP - Wordpress - Global Variables

by 3 replies
4
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?
#programming #global #php #variables #wordpress
  • 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.
  • 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.
  • How did you solve it though?

Next Topics on Trending Feed