1. Home
  2. Docs
  3. Theme Functions (functions.php)
  4. Search Count Function
  5. Scripts

Scripts

function search_results_title() {
	if( is_search() ) {
	
		global $wp_query;
		
		if( $wp_query->post_count == 1 ) {
			$result_title .= '1 search result found';
		} else {
			$result_title .= $wp_query->found_posts . ' search results found';
		}
		
		$result_title .= " for “" . wp_specialchars($wp_query->query_vars['s'], 1) . "”";
		
		echo $result_title;
	
	}
}

description:

display the total search results found

Was this article helpful to you? Yes No

How can we help?

Leave a Reply

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