Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 6th Mar 2011, 05:06 PM   #1
I'm Kind Of A Big Deal
 
jasonmorgan's Avatar
 
Join Date: 2009
Posts: 1,997
Thanks: 58
Thanked 417 Times in 307 Posts
Default
PHP - Wordpress - Global Variables
Share on: 
fb share twitter share gplus share more share

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?

I'm all about that bass.
jasonmorgan is offline  
Unread 6th Mar 2011, 06:40 PM   #2
I'm Kind Of A Big Deal
 
jasonmorgan's Avatar
 
Join Date: 2009
Posts: 1,997
Thanks: 58
Thanked 417 Times in 307 Posts
Default
Re: PHP - Wordpress - Global Variables
Share on: 
fb share twitter share gplus share more share

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.

I'm all about that bass.
jasonmorgan is offline  
Unread 7th Mar 2011, 04:40 AM   #3
Programmer of Awesomeness
War Room Member
 
andreasnrb's Avatar
 
Join Date: 2009
Location: Sweden
Posts: 164
Thanks: 9
Thanked 12 Times in 12 Posts
Default
Re: PHP - Wordpress - Global Variables
Share on: 
fb share twitter share gplus share more share

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.

Excellent product, Excellent support, great for affiliate marketers (Amazon, ClickBank etc)
[SIGPIC][/SIGPIC]
http://andreasnurbo.com
andreasnrb is offline  
Unread 18th Mar 2011, 09:44 PM   #4
Warrior Member
 
Join Date: 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: PHP - Wordpress - Global Variables
Share on: 
fb share twitter share gplus share more share

How did you solve it though?
voitenkos is offline  
Closed Thread


Bookmarks

Tags
global, php, variables, wordpress


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




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