I'm writing a plug-in and need to get the post ID. I stripped the plug-in code down to this and it's not working.
<?php
/*
Plugin Name: Post-Comment Limit
*/
function lpu_show_id() {
global $post;
$postid = $post->ID;
return $postid;
}
$id = lpu_show_id();
echo "Post: ".$id;
?>
I tried $wp_query, not working.
function lpu_show_id() {
global $wp_query;
$thePostID = $wp_query->post->ID;
return $thePostID;
}
I presume I'm missing something easy. Help, please :(