getting the total count of search results in wordpress getting the total count of search results in wordpress wordpress wordpress

getting the total count of search results in wordpress


Try this code,

$allsearch = new WP_Query("s=$s&showposts=0"); echo $allsearch ->found_posts.' results found.';

Hope this will helps you.

For more please visit,

Result Count in WordPress

Display Search Result Count


Once you are already in a search query, you can as well use the global $wp_query.

See example below:

<?php   global $wp_query;   $not_singular = $wp_query->found_posts > 1 ? 'results' : 'result'; // if found posts is greater than one echo results(plural) else echo result (singular)   echo $wp_query->found_posts . " $not_singular found";?>