[wp-hackers] problems with wpquery

Mark E mark at simplercomputing.net
Tue May 11 02:52:41 UTC 2010



Khaleel Abdul Karim wrote:
>    *     global $wp,$wp_query;
>         $wp->parse_request();
>         $wp->query_posts();
>         print_r($wp_query->queried_object_id);*
> 
> I have tried this code to get id of a queried post/page/cat etc. But *
> $wp_query->queried_object_id* returns me a NULL value. Any solution.
> Thanks in advance.

You can dump the $wp_query array to see what's in it, look for the field 
you want, and go from there. Dump it like this:

var_dump($wp_query);

Then load a page and view the HMTL source of the page to see the dumped 
output formated with line breaks (easier to read that way).

Mark


More information about the wp-hackers mailing list