[wp-hackers] Finding post ID while in header

CaptSolo captsolo at gmail.com
Fri Mar 24 18:21:51 GMT 2006


On 3/22/06, David House <dmhouse at gmail.com> wrote:
> On 21/03/06, Andy Skelton <skeltoac at gmail.com> wrote:
> > Don't we have API for this stuff? Something like get_queried_object()?
> > When was that introduced? I've fallen into Trunk and I can't get out.
>
> There's get_queried_object() and get_queried_object_id(), yeah. Also,
> in core, we now have get_the_ID().

Thanks. None of these worked for me with WP 1.5 though. I see in the
source that the functions get_queried_object() and
get_queried_object_id() are defined, but I can't call them from the
plugin.

$posts[0] worked fine.

Also need to get author's ID if the requested page is author's page.
Probably get_queried_object_id() would have helped. Since it does not
work for me, I did this instead:

global $wp_query;
$user_id = $wp_query->get('author');

Is that a correct way to get author's ID?
Or is there a better one?

Thanks,
Uldis

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


More information about the wp-hackers mailing list