I'm trying to figure out if this is by design, a bug or a feature I should try to request. I created a plugin and added the following code:

function test_wp() {
    echo '<div style="position: absolute; border: 3px solid #dcdcdc; background: #ffffff; padding: 20px; left: 200px; top: 100px; font-size: 30px; z-index: 9999;">It worked</div>';
add_action('wp', 'test_wp');

I'm essentially looking for instances where the 'wp' hook does/doesn't get triggered. It doesn't load on the admin dashboard, which is obvious since it's not loading any single WP object. Whenever I click into "All Posts" it does appear to get triggered. Which is what I expected to happen.

Now, when clicking edit on any existing post, it appears 'wp' hook is not getting triggered on the post editor pages. It seems to me that the 'wp' hook should be getting called here, since it's loading a post and it's respective data directly onto this page. Yet the trigger doesn't seem to load.

Am I missing some logic behind it not loading here?

I am able to trigger the 'posts_selection' hook, which according to the Action Reference list happens right before 'wp' hook runs. That said, I have no idea what 'posts_selection' is actually doing, since the documentation for it is empty.

I am currently running WordPress 3.6.1 and had the same issue in 3.6.0. I haven't tried any versions prior to 3.6.

1 Answer 1


No, 'wp' action hook is not triggered on post edit page.

This hook is a query-related hook, it means that it runs everytime a posts query is triggered from an url.

For this reason it's a more frontend hook (it runs on every frontend request), even if is triggered in some edit pages, more specifically, in the admin pages that do a post query: edit.php (so post, page and every cpt list) and upload.php (that show a list of media, i.e. attachment post type).

When you are on single post edit, no post query is triggered, because the current post is retrieved by WP with get_post().

'posts_selection' is another query-related hook, so it runs on every frontend request and on admin pages that run a post query (just like the 'wp' hook).

If you need and early action hook that runs on post edit page, a good idea is look at 'load-post.php' hook (one of the 'load-{$page}' hooks), that is fired only on post edit page.

In a function that runs on that hook, you can access to the post id being edited using $_GET['post'] variable.

  • If there any block scheme or image where we can check what and where is called? Bc this list doesn't show anything right. It say admin has wp action but edit page it is not admin? codex.wordpress.org/Plugin_API/Action_Reference
    – fdrv
    Commented Mar 28, 2016 at 18:31
  • load-edit.php doesnt called on single edit page and also it called on list of posts to edit
    – fdrv
    Commented Mar 28, 2016 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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