[wp-hackers] Finding post ID while in header

CaptSolo captsolo at gmail.com
Tue Mar 21 20:18:05 GMT 2006


Hi!

Could you suggest how to find out what the post ID is while in header?
E.g., how to display a post ID (if this is a single post page) within
HTML comments.

I have registered a plugin action with add_action( 'wp-head',
'display_link' ) and now need to find the post ID from within that
function:

function display_link() {
  if ( is_single() ) echo "<!-- Post ID = " . $post->ID . " -->\n";
}

Of course, there's no post ID echoed.

Adding the post loop to this function (which I am not sure is the
right thing to do) just leads to error messages about unexpected '}'.

Thanks,
Uldis

[ http://captsolo.net/info/ ]


More information about the wp-hackers mailing list