Dukeo » WordPress » Search Results Count: How To Display The Number In WordPress

Search Results Count: How To Display The Number In WordPress

Steven WordPress

Everybody knows that WordPress search is not one of the strongest side of our preferred CMS. One of the steps you can take to improve your visitor’s experience is to display the number of results returned by a given research.

In order to display the number of search results, you need to open your search template file search.php.

Search for:

<h2 class="pagetitle">Search Results</h2>

And replace it with:

<h2 class="pagetitle">Search Results for <?php $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(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?></h2>

That’s all folks!

If you enjoyed this article,
Get email updates

Join for Free »