[wp-hackers] How to make $post->ID global
goldenapplesdesign at gmail.com
Fri May 11 03:47:04 UTC 2012
> Your include file runs before $post is defined.
> The trick to make your include file function is to add it or its code with
> an action that takes place after $post has been defined.
> If header.php is okay, use add_action( 'wp_head', 'your_function' ) where
> your function runs the code you want to add to the theme header.php file.
Or, if you need the post ID before then (but after at least the 'wp' hook),
use the function get_queried_object_id()
More information about the wp-hackers