WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a conditional tag (or a similar concept) that can tell me wether the search returned posts or not?

share|improve this question
global $wp_query;
echo $wp_query->found_posts;
share|improve this answer
Or if( have_posts() ) should pretty much do the same, ie. tell you if there are more than 0 posts returned in the query. – t31os Jan 22 '11 at 10:21

Your Answer


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