[wp-hackers] Finding post ID while in header

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


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 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 '}'.


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

More information about the wp-hackers mailing list