[wp-hackers] get_header hook runs twice for me.

Haluk Karamete halukkaramete at gmail.com
Thu Feb 28 01:47:26 UTC 2013

I got this

function get_context()
global $wp_query;
echo "<hr>HALUK<hr>";

When I go visit an archive a page, I see that the get_context runs twice. I
know it runs twice because I see my name repeated twice in between the
Anyway, in the first run, I get the wp_query output in a ,very limited and
useless fashion. It's limited and got no data in it, something like this;

WP_Query Object
    [query] =>
    [query_vars] => Array

    [tax_query] =>
    [meta_query] =>
    [queried_object] =>
    [queried_object_id] =>
    [request] =>
    [posts] =>
    [post_count] => 0
    [current_post] => -1
    [in_the_loop] =>
    [post] =>
    [comments] =>
    [comment_count] => 0
    [current_comment] => -1
    [comment] =>
    [found_posts] => 0
    [max_num_pages] => 0
    [max_num_comment_pages] => 0
    [is_single] =>
    ... some more is_this and is_that... cut for brevity.
    [is_posts_page] =>
    [is_post_type_archive] =>
    [query_vars_hash] =>
    [query_vars_changed] => 1
    [thumbnails_cached] =>

As you see even the found_posts comes up as 0.

In the second running though, I I get all the context one can wish for in
regards to the current page.
Including the correctly calculated [found_posts] data.

Why is that? Why am I getting this action hook runs twice?

More information about the wp-hackers mailing list