[wp-testers] Conditional tags not working

Nathan Rice ncrice at gmail.com
Sun Jan 17 05:48:54 UTC 2010


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');
?>

That code does NOT work.

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.

------------------
Nathan Rice
WordPress and Web Development
www.nathanrice.net | twitter.com/nathanrice


On Sun, Jan 17, 2010 at 12:30 AM, Austin Matzko <if.website at gmail.com>wrote:

> On Sat, Jan 16, 2010 at 11:21 PM, Nathan Rice <ncrice at gmail.com> wrote:
> > As this post points out:
> >
> http://weblogtoolscollection.com/archives/2010/01/16/fix-for-is_home-is_archive-not-working/
> >
> > conditional tags like is_home(), is_page, is_archive(), etc., are all
> > seemingly not working. I've noticed this as well (running 2.9.1).
> >
> > I believe that it might work in some circumstances (like in the loop?),
> but
> > I am currently running into the problem when trying to conditionally do
> > something in the theme's functions.php file.
>
> Could you be more specific about what you're trying to do?  I wouldn't
> expect them to work when the theme's functions.php file is included,
> for example, because that happens before the page query is even
> parsed.
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>


More information about the wp-testers mailing list