All Collections
FAQ's and Troubleshooting
How to Display the Search Result Count/Number within the default Search Results Page
How to Display the Search Result Count/Number within the default Search Results Page

Learn How to Easily Showcase the Total Number of Search Results in Your Default Search Results Page

Fozla Rabbi avatar
Written by Fozla Rabbi
Updated over a week ago

Divi offers two types of search results pages: the default search results page and a customizable search results page template created with the Theme Builder.

Displaying the Search Results Count on the Default Search Results Page:

To showcase the search results count on the default search results page, you can integrate custom PHP code without the need to modify any Core theme files.

Note: This method requires a child theme to be installed and active. The child theme can be created using this tutorial.

Add the provided code to your Child theme's functions.php file, or utilize the Code Snippets plugin for an easy way to incorporate this snippet and display the search results count.

You can follow this guide to learn more about adding PHP codes to Divi.

function add_search_results_count_before_content() {
if (is_search()) {
echo '<div class="search-results-count">Number of Results: ' . $GLOBALS['wp_query']->found_posts . '</div>';
}
}
add_action('et_before_main_content', 'add_search_results_count_before_content');

And add the following custom CSS to WordPress Dashboard > Divi > Theme Options > Custom CSS field to adjust the position of the search results number:

.search-results .search-results-count {
padding: 1% 17% 0%;
text-align: left;
}

Did this answer your question?