How To Get The Total Number Of Posts In A WordPress Search Results Page

As you probably know your search result page already has a list of posts that were found. That means that you do not need to include any additional binder to the posts data. If you wish to know what is the total number of post that were found for a particular search term, in you search page you can include the following code:

 

<p><strong>{{$wp_query.found_posts}}</strong> results found for "<strong>{{$smarty.get.s}}</strong>"</p>

 

The previous code shows how to access the $wp_query object to get the total number of posts found. You can also access the last search term directly from the global $smarty object ($smarty.get.s).

Leave a Reply

Your email address will not be published. Required fields are marked *