Include count in search results

searchAnother little tweak to the blog today (my plan is to conquer WordPress one tweak at a time and maybe learn a bit about php in the process).

This time I’m including a count of search results in the search page. Thanks to Pro Blog Design and their article 3 codes for a far better WordPress search page for this.

I now realise the theme I’m using seems a little bit out of whack, when I looked in my search.php page only to find a single line to include the contents of archive.php, so need to have a proper dig sometmie and understand how it all hangs together.

So, in search.css or in my case, somewhat bizarrely, in archive.css, I replaced:

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


<h2 class="pagetitle">Search Result for post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?&gt;</h2>

Nice and easy and the results now come back with a count. Next up, make it a proper search results page, instead of full posts…

Leave a Reply