Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   PHP - Wordpress - Global Variables (https://www.warriorforum.com/programming/343516-php-wordpress-global-variables.html)

jasonmorgan 6th March 2011 05:06 PM

PHP - Wordpress - Global Variables
 
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?

jasonmorgan 6th March 2011 06:40 PM

Re: PHP - Wordpress - Global Variables
 
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.

andreasnrb 7th March 2011 04:40 AM

Re: PHP - Wordpress - Global Variables
 
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.

voitenkos 18th March 2011 09:44 PM

Re: PHP - Wordpress - Global Variables
 
How did you solve it though?


All times are GMT -6. The time now is 10:35 PM.