is_admin() should be working perfectly fine, as core uses it.

You canot use template conditionals in global scope in functions.php however, This is not possible due to the theme being included earlier than WordPress has determined what type of query it is.

Try using them at a later stage in the loading process and you'll find they work, Using a custom function is REQUIRED, and cannot be worked around if you want to use it within functions.php. An example is:

add_action('template_redirect', '_theme_comment_reply');
function _theme_comment_reply() {
   wp_enqueue_script( 'comment-reply' );
}

Alternativly, You can use them at a later stage, Such as within your header.php file before any output occurs. At this point WordPress has determined what the request is, and the conditionals will be populated.

On Sun, 17 Jan 2010 16:48:54 +1100, 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');
?>

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 <[email protected]>wrote:

On Sat, Jan 16, 2010 at 11:21 PM, Nathan Rice <[email protected]> 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
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-testers

_______________________________________________
wp-testers mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-testers



--
Dion Hulse / dd32

Contact:
 e: [email protected]
 msn: [email protected]
 skype: theonly_dd32
 Web: http://dd32.id.au/
_______________________________________________
wp-testers mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-testers

Reply via email to