[wp-hackers] get_post_meta in wp_head?

Johan Eenfeldt johan.eenfeldt at gmail.com
Thu Jan 8 03:20:52 GMT 2009

On Thu, Jan 8, 2009 at 2:55 AM, Mindshare Studios
<info at mindsharestudios.com> wrote:
> Is it possible to access post custom fields inside of plugin function
> that hooks into wp_head?

Kind of.

> Here's my code (however $post_ID isn't being returned):
> global $post_ID;

None of the global post variables are available outside the loop.

If you want it, you have to get it from the global $wp_query.

I think you can find it in $wp_query->post->ID.

Other relevant functions could be: have_posts(), is_single(), perhaps is_post().

/ Johan

More information about the wp-hackers mailing list