I have a code that displays results for search but, I need it to include the count not just keyword searched

<h1 class="font-thin h2 m-b">
printf( esc_html__( 'Search Results for: %s', 'musik' ), '<span class="font-bold">' . get_search_query() . '</span>' );

  • And what would you like to see instead? Commented Jan 18, 2019 at 6:13
  • i would like to see the number of search results found Commented Jan 18, 2019 at 6:40

2 Answers 2


If you are in the search results template then you can find out the count by using the below code.

global $wp_query;
$count =  $wp_query->found_posts

variable $count contains the count of post against the search.


Please open and modify this line in search.php.

<h1 class="font-thin h2 m-b">
Search Result for <?php 
/* Search Count */ $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(' &mdash; '); 
echo $count . ' '; _e('articles'); 



Reference link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.