[wp-hackers] $postnow?
Ryan Bilesky
rbilesky at gmail.com
Wed Sep 22 06:23:42 UTC 2010
I use
global $post;
echo $post->ID;
On Tue, Sep 21, 2010 at 10:58 PM, Mike Schinkel <mikeschinkel at newclarity.net
> wrote:
> Here's another one that I've probably missed though not for lack of
> looking, hoping you can help.
>
> We've got $typenow to tell us what post_type we are currently acting on,
> $pagenow to tell us what the current .PHP page is and $taxnow to tell what
> taxonomy we are working with but as far as I can tell there's no equivalent
> way to find the post ID we are currently working with.
>
> I'm finding it very hard to write robust code that gets it right 100% of
> the time because it appears it can be at least any one of the following and
> it's hard to get all of the contexts completely right:
>
> $_GET['post']
> $_GET['post_id']
> $_GET['page_id']
> $_POST['page_id']
> $_POST['page_ID']
>
> And there may be other ways I've missed. Am I overlooking something
> obvious? Is there some way to determine the $post->ID that I can depend on?
>
> Thanks in advance.
>
> -Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list