I need to register an action via

add_action('wp', function(){...});

The action works in frontend, but in backend and login page it doesn't work. It seems as if 'wp' hook doesn't exist for administration and login page.

Am I missing something or is there any alternative?

Use case description: I have a special tag (custom taxonomy term) for one of the pages. If user is not logged in and tries to access the backend s/he should be redirected to the page that has the tag. To find out which page has that tag I use WP_Query with tax_query. Therefore, I need a hook that is triggered after custom taxonomies (and custom post types) are registered, but also that is triggered before headers are set.

Any idea?

1 Answer 1


I just observed the same problem, and fixed it by using the "admin_init" Action instead. I only want it to fire in Admin, but if you want it to fire for Public as well as Admin, simply use two add_action's, one for wp and admin_init, though I would make it conditional:

if ( is_admin() ) {
   add_action( 'admin_init',...
} else {
   add_action( 'wp',...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.