How To Show The Number Of Search Results In The Divi Search Results Template Tutorial by Pee Aye Creative

How To Show The Number Of Search Results In The Divi Search Results Template

Nelson Miller Pee Aye Creative
In this tutorial I will show you how to show the number of search results in the Divi search results Theme Builder template.

Join subscribers on our YouTube channel and enjoy other Divi video tutorials!

Search Results Template Setup

This tutorial will not cover how to set up the search results template. If you need help with that, I suggest checking our other tutorial: How To Customize And Style The Divi Search Module And Create A Search Results Page.

To get up to where our tutorial starts, you would need to do these steps:

  1. Create A Theme Builder Template Assigned To “Search Results”
  2. Add a Blog module and set it to “Show Posts For Current Page”

Be sure to watch the video for this tutorial, it will really help!

1. Add The Shortcode To A Text Module

The first step will be to add a new Text module above the Blog module. This will be used for the main heading that reads out with the number of results. To make this work with a dynamic number, we need to add a shortcode to the Text module. The shortcode will output the code which will say the number of results, like “23 results for “divi”.” The shortcode will be powered by a snippet, which we will talk about in step #2.


add shortcode to show the number of search results in Divi

2. Add The PHP Code

The second step now is to add the PHP code that is working behind the scenes and connected to the shortcode. This step involves pasting the PHP code snippet below into your website. There are a number of locations to add this, and it will totally depend on your website and experience.

If you have a child theme, then you would add this snippet to the functions.php file of a Divi child theme. If you don’t already have one, you can download our free Divi child theme here.

If you want the easy way, then I will recommend installing the Code Snippets plugin. It is a great plugin that allows you to add snippets easily in the backend of your admin area. After activating, just go to Snippets>Add New, write a title, paste the snippet, and click the save and activate button. Here is how that will look:

number of search results code snippet


function pa_search_results_count_shortcode($atts, $content=null){
    extract( $atts = shortcode_atts(
            ''             => '',
            ), $atts, 'pa_search_results_count' ) );

        global $wp_query;
        $items_total = $wp_query->found_posts;
        echo $items_total.' Results for "'.get_search_query().'"';

    return ob_get_clean();
add_shortcode('pa_search_results_count','pa_search_results_count_shortcode' );

Edit The Text

If you want to edit the text, you can easily do so by editing the text within the code. Look for the “Results for” text and this is where you can carefully edit it. For example, you may change it to Search Results For Your Query: and this would read out as “[x] Search Results For Your Query: [search term]”

Do It With Our Divi Search Helper!

Make life easier and use the Divi Search Helper instead! This innovative plugin upgrades the existing Divi Search module with all the missing features provided by our addon with new design settings, advanced search criteria options, and improved search result pages.

Divi Search Helper Plugin By Pee Aye Creative

Last updated Oct 10, 2023 @ 5:44 pm


Each month we send out a roundup email newsletter with the latest tutorials, product updates, helpful resources, and any other industry or personal news. Occasionally we send an extra separate email here and there if we just can’t wait! So that’s what you will get if you subscribe, and you can always unsubscribe at any time if you just can’t take it anymore :)

Blog Post Optin

Please share this post!

Nelson Lee Miller (aka The Divi Teacher)

Nelson is the owner of Pee-Aye Creative in the beautiful state of Pennsylvania. He loves helping small businesses, exploring outdoors, building websites with Divi, and teaching others.
Pee Aye Creative Black Friday Sale

Our Once A Year Sale Is Happening Now!!!

25% OFF all Divi Plugins, Courses, and Child Themes!

Shop The Sale Now!

Asset 7

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Pee Aye Creative Black Friday Sale

Our Once A Year Sale Is Happening Now!!!

25% OFF all Divi Plugins, Courses, and Child Themes!

Shop The Sale Now!

Divi Tutorials On YouTube

Our videos have views! Join subscribers and enjoy over video tutorials!

Visit Our Channel

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy


Submit a Comment

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

Recent Posts


Your Cart