[wp-testers] Conditional tags not working

Andrew Nacin wp at andrewnacin.com
Sun Jan 17 21:09:49 UTC 2010


On Sun, Jan 17, 2010 at 3:15 PM, Nathan Rice <ncrice at gmail.com> wrote:

> is_admin() does indeed work when used in functions.php.
>

is_admin() works as it isn't like any of the other conditionals. It is
defined early on (in wp-includes/load.php, which is one of the first files
wp-settings.php includes) and relies on a constant set in the admin.php
bootstrap, not the current query like the other conditionals.

So, as a followup question ... what hooks are best to use if I want to be
> able to use the conditionals? Someone already mentioned template_redirect
> ... are there any others? Is there a good resource that defines what hooks
> are fired before and after WP knows what type of query it is?
>

Adding to Austin's suggestion to review wp-blog-header.php, you can add this
to your functions.php file to get a dump of every hook that runs:

add_action( 'all', 'dump_all_hooks' );
function dump_all_hooks() {
   var_dump( current_filter() );
}

You could combine that with function_exists or did_action etc. to only see
hooks after something has been loaded or is run.


More information about the wp-testers mailing list