How to get number of results from query_posts?

SOLVED:

if (have_posts()) : 

        $args = array(
            'showposts' => '5',
            'paged' => $paged
        );


        $thePosts = query_posts($args);


         global $wp_query; 
         echo $wp_query->found_posts;
    ...

To display the number of results of a search, use:

Search Result for 

<?php 
/* Search Count */ 
$allsearch = &new WP_Query("s=$s&showposts=-1"); 
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count; _e('');
 _e('<span class="search-terms">'); 
echo $key; _e('</span>'); 
_e(' &mdash; '); 
echo $count . ' ';
 _e('articles');
 wp_reset_query(); 
?>

This was taken from: WP Beginner.

Tags:

Wordpress