[wp-hackers] Weird 1.5 template behaviour

Ryan Boren ryan at boren.nu
Tue Jan 18 00:13:41 GMT 2005


On Tue, 2005-01-18 at 01:12 +1300, Stephen Cropp wrote:
> Stephen Cropp wrote:
> > Okay... This is a little bizarre and I cannot find any reason as to why 
> > this might happen.
> > 
> > Here are some of the errors that are appearing when you load the page...
> > 
> > -----8<-----
> > Warning:  Variable passed to each() is not an array or object in 
> > /home/scropp/public_html/includes/lib-xmlrpc-class.inc.php on line 70
> > 
> > Warning: main(): Failed opening '/includes/buttons.php' for inclusion 
> > (include_path='.:/usr/lib/php:/usr/local/lib/php') in 
> > /home/scropp/public_html/dev/wp-content/themes/dgenx/sidebar.php on line 21
> > 
> > Fatal error: Call to a member function on a non-object in 
> > /home/scropp/public_html/dev/wp-content/themes/dgenx/sidebar.php on line 22
> > -----8<-----
> > 
> > So my simple question is, why is get_header(); not working while a 
> > simple include(); does? That is ultimately the only difference between 
> > the two. I've tried tracing it, but I really cannot find a reason for it 
> > to do so.
> > 
> > Anyone have any ideas? This one is kind of bugging me ;-)
> 
> 
> Further to this, it appears that it happens with all get_*(); functions. 
> I tried require('header.php'); and left get_sidebar(); there and the 
> sidebar still had errors in it. So it appears that if I use get_*(); to 
> include any part of the theme, even with a global $dgenxhome, those 
> parts can't access the vars in dgenx.conf.php for some reason.
> 
> But the weird part is the functions still works :-|
> 
> So for now, I am sticking with require(); to put the various parts of 
> the theme together.
> 
> Still, any ideas would really be appreciated.

Files included from a function get that function's context rather than
the global context.  That's why get_header() and friends use
load_template() to setup the standard WP environment.  Non-WP global
variables will not be present, however.

Ryan




More information about the hackers mailing list