I'm trying to get page post meta in my header so I can set some meta tags. I tried to get the global post variable but it only return true.

    global $post;
    global $wp_query;
    echo print_r($post);
    echo print_r($wp_query->post);

All I get is 11 - is there a way to get my post meta in the header?

1 Answer 1


Use get_the_ID(), the post object is not set up completely on wp_head():

if ( is_singular() )
    $post = get_post( get_the_ID() );

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.