On Sat, Jan 16, 2010 at 11:48 PM, Nathan Rice <[email protected]> wrote: > OK, something simple and straightforward ... > > Let's say I want to create an admin settings page. I have the code loaded in > a separate file, and want to use the functions.php file to include it, but > there's no need to load the code into memory when viewing the front-end > (non-admin). So, I wrap the include in conditional tags ... > > <?php > if(!is_admin()) > require_once(TEMPLATEPATH.'/admin_menu.php'); > ?>
You do mean "is_admin()", not "! is_admin()", right? > That code does NOT work. It should, assuming you remove the "!". > Or, let's say I want to move the comment reply script call from the > header.php to the functions.php, where it really belongs ... > > <?php > if(is_singular()) > wp_enqueue_script( 'comment-reply' ); > ?> > > See? And please don't tell me to write a custom function and use hooks. > That's not the issue here. The issue is the fact that conditionals aren't > working properly. I'm almost positive that this used to work, which is why > I'm wondering why it's not working now. Unfortunately, attaching callback functions to the correct hooks is the issue here. It doesn't make any sense to check is_singular() at the top of functions.php, because when functions.php is included and that code executed, WordPress doesn't yet know what the queried page is--whether it's singular, a page, or whatever. I would be really surprised if the above example has worked in any version of WordPress. It's impossible for WordPress to determine whether the current query is for a singular object, before it has even parsed the query. _______________________________________________ wp-testers mailing list [email protected] http://lists.automattic.com/mailman/listinfo/wp-testers
