How to get the total count of results, in the search results page in wordpress ... i think my question is clear .i need the total number of search results that displayed in the search results page .And also need to find the count of results from page and post separately
what i have tried is
<?php echo count($posts); ?>
by using this i got the total number of search results . but i also need the count of pages and posts in the search results
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";
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With