0

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.

<?php
    global $post;
    global $wp_query;
    echo print_r($post);
    echo print_r($wp_query->post);
    die();
?>

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

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, privacy policy and cookie policy

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