Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

By the time index.php runs, it seems as though there is already a query populated.

How can I find out what that query's query string is?

eg. new WP_Query([query string is here])

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Take a look at global $query_string;.

Or var_dump( $GLOBALS['wp_query'] );.

share|improve this answer
<?php var_dump( $GLOBALS['wp_query'] ); ?>

and if you have custom loop in your template, dont forget to use (query_post()) <?php wp_reset_query(); ?> or (new WP_Query) <?php wp_reset_postdata(); ?> :)

Function should be called after The Loop to ensure conditional tags work as expected.

share|improve this answer
    
Please use get_posts() for that. –  kaiser Apr 20 '12 at 21:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.