getting post ID from a plugin (again…)
-
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 ??
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘getting post ID from a plugin (again…)’ is closed to new replies.