Skip to main content
Easily create better & faster websites with the Total WordPress Theme Learn More
(opens a new tab)
Tips

How to Customize Search Page Results in WordPress

How to Customize Search Page Results in WordPress

When you search on a regular search engine like Google, it’s highly unlikely that you’ll come up with no results (unless you search for something utterly nonsensical, but even then…). However, this can happen more regularly than one would like when using a WordPress website’s internal search function.

Many of your website visitors will want to find more information about you, your business, or your products. If they hit a blank page after typing a query into your search bar, however, chances are they will leave your site. This is especially true if they are used to Google or a similar search engine.

Internet users expect certain features from the websites they visit. It’s important that you work with their expectations when it comes to searching. Having a custom search page that includes the items they’re used to will help keep them interested and engaged in your content.

In this post, we will discuss what search results pages are and why they’re important. Then, we’ll outline how to customize your WordPress results page to include the functionality your readers expect to see. Let’s get started!

What are WordPress Search Results Pages?

WordPress Search Results Pages
Example of search results for “search”

When one of your readers types a word or phrase into the search box on your WordPress site, they’ll see a page listing all the content that matches their query. This is known as a search results page. Of course, an internal search results page is different from the results you would see on a search engine like Google. For one thing, the internal page will only list items that are available within your site, rather than across the entire internet.

An internal search results page is important for any site that features text content and is accessible through standard search engines. Generally, one of three things will happen when someone lands on your site from a basic internet search. They will immediately find what they are looking for, they will use your built-in search to find the information, or they will leave your site. Therefore, your chance of keeping readers on your site relies on their ability to find what they are looking for quickly. Enabling visitors to search and view results on your site is one of the easiest ways to keep them around for longer.

Why to Customize WordPress Search Results Pages

Visitors come to your website with certain expectations. While they aren’t looking for the same results they would get from Google, they may expect to see similar features. This can include suggested spellings, content suggestions based on their initial search, and more.

Having a customized search results page can keep your readers engaged with your site and its content, even when their searches come up dry. Plus, you’ll be providing your readers with everything they expect from a standard search engine. By mimicking popular search engines, you can also lower bounce rates on your site.

If done correctly, a custom results page offers several additional benefits. It can:

  • Help visitors find what they are looking for
  • Keep visitors on your site longer
  • Offer related information searchers may not have known they needed
  • Show some personality
  • Show you care about the little things, including being helpful

In the end, customizing your WordPress search results to more closely imitate a traditional search engine creates value for you and your visitors. Best of all, you can accomplish it easily through the use of plugins!

How to Customize Your WordPress Search Results Pages

The versatility of WordPress enables you to easily customize your search results. You can use code to alter the search.php file, for example, or you can use a plugin. We recommend the latter approach, as plugins are easier for most WordPress users to install and maintain.

There are several options you can use to customize your internal search results pages. While you could always dive into the search.php code (though this is best left to experienced users comfortable with PHP and CSS coding), there are several plugins you can use to implement simialr changes. Finding the functionality that works best will depend on you and your site. Small personal sites may benefit from free plugins, while larger sites might need a premium solution.

As always, we also recommend that you back up your WordPress site before making any updates or changes. Let’s dive in!

Search & Filter By Code Amp

One of the best tips I’ve ever heard about internal site search results pages is the closer you can make them look like standard Google search results pages, the better. One way to do this is to include the search term your visitor searched for at the top of the search results page. This is a simple technique to show visitors a search did occur even if it came up empty (and perhaps a typo was the culprit). It also enables your readers to double check that they entered the right phrase, and that they spelled the words correctly.

Search & Filter is a free plugin that works with the default search function for WordPress. It will enable users to search every non-password protected page on your site. In addition, it offers functionality that makes it possible to feature the search term at the top of results pages, or even provide users an option to order search results (note this is in the Pro version).

Include the Search Term on Search Results Pages

To do this manually you will need to start by creating a child theme (if you’re not sure how, checkout our guide on how to create a WordPress child theme).

Next, create a search.php file in your brand new child theme and copy over the code from your old theme (you can find this by either opening up theme files on your server via FTP, or from your WordPress dashboard under Appearance > Editor > Search.php). Now you can replace the default title in your child theme’s search.php with the following:

<h1 class="search-title">
<?php echo $wp_query->found_posts; ?> <?php _e( 'Search Results Found For', 'locale' ); ?>: "<?php the_search_query(); ?>"
</h1>

This will display the title with the count of the posts found followed by the term that was searched. So it would look something like “15 Search Results Found For: My Search Query”.

Highlight the Search Term in Results

Highlight Search Terms Plugin

Another thing you might want to do is highlight the search term in the search results. This way, when visitors to your site are presented with search results, their search term is highlighted within the individual results. The plugin Highlight Search Terms serves this role well. It’s simple but can help direct your visitors more specifically to what they’re looking for.

2. Add Suggested Spellings in Case of Typos

Relevanssi Better Search Plugin

Thanks to the popularity of Google and other search engines, most site visitors expect to see spelling suggestions when they interact with your search function. Adding this feature to your results pages improves the user experience, by helping them find what they’re looking for even if they don’t know how to spell it.

With over 100,000 active installs, Relevanssi is one of the most popular WordPress plugins for search. Rather than using WordPress’s default functionality, Relevanssi replaces the search feature altogether. Its free services are perfect for small or personal sites, while the premium version offers amazing functionality for large and multi-site managers. In addition to its suggested spelling feature, this plugin provides an array of options, including the ability to search tags, comments, and categories.

3. Add Suggested Pages to Maintain Interest in Your Site

Better Search Plugin

One of the best ways to use your results pages, aside from providing the searched-for information, is to serve up content that is similar to what users are looking for. If you have ever searched Amazon for a product, you’ve probably seen suggestions for other products based on that search. This method of putting valuable content in front of visitors can boost the amount of time they spend on your site. And by suggesting pages for readers to go to – even if it’s not related to their search query – you can do a lot toward decreasing your bounce rate.

If you are looking for search functionality that behaves the way Amazon or eBay does, a simple option we recommend is the Better Search plugin. Once installed, you can insert a heat map for your most popular searches in the form of a widget. This will ensure visitors will be presented with plenty of options for where to go next.

Ivory Search

Another way to keep people on your site and engaged in their searches is to add a search box on the search results page if there isn’t one already included in your theme. This is especially helpful if no results are returned and you wish to prompt users to try a different search query. An easy way to add a search box is with the free Ivory Search plugin. While this plugin has grown to include many search features, it’s still just as easy to install and use the plugin settings to customize your search form and results.

You can also add a search box directly to any page (via your child theme, as mentioned above) by using the core WordPress function “get_search_form();”.

<?php get_search_form( true ); ?>

This will display the searchform as defined by the searchform.php theme file or if one doesn’t exist WordPress will output HTML for a standard search form. You can learn more at the CODEX.

Or, if by chance you are using a block based WordPress theme, you can simply customize your menu by adding in the Search block.

Gutenberg Add Menu Search

To do this, go to Appearance > Editor > Template Parts > Header then insert the Search block. It’s that easy with Gutenberg’s full site editor.

Which ever option you choose, a menu search will make it so your visitors have no excuses for getting off track on your site. When you’re always steering them back in the right direction, you ensure you’re doing your part to enhance people’s experience on your site. And I can assure you right now, that kind of attention to detail doesn’t go unnoticed or unappreciated.

Ajax Search Lite Plugin

The last option we want to mention today to keep readers engaged with your site is to add Ajax search results so your readers can use a “live” search. The free Ajax Search Lite plugin allows users to search your site with results updated as they type. The plugin includes added options for category filter, Google autocomplete and keyword suggestions.

For more options consider upgrading to Ajax Search Pro. The premium version of the plugin adds support for bbPress, BuddyPress, WooCommerce and JigoShop so users can search all of your custom post types. Plus there are features for caching, custom fields, 100+ design themes, 4 layouts and lots more.

Toolset Search

Or consider using Toolset Search. In addition to support for Ajax search results, the plugin adds tons of other options for filters, map based results, grid and list layouts, pagination and more.

Conclusion

While many WordPress users think to add the search widget to the sidebar of their sites, a lot forget about what the output of such searches will be. And that’s a major oversight.

You want to make sure every single page of your site is working hard for you – even the search results pages. While most readers may be interested in your home page or core offerings, they probably come to your site looking for something specific. Although your site is likely not a search engine, it’s best to provide the help and functionality visitors are accustom to. You never know how a single page can affect individual users. Present the right visitor with the right information at the right time and you stand to not only keep that visitor on your site for longer but also turn them into a loyal customer.

Have you done any customization on your search results pages? If so, what’s worked best for you? What have you found to be the most effective addition? As always, let me know in the comments.

Disclaimer: WPExplorer may be an affiliate for one or more products listed in the article. If you click a link and complete a purchase we could make a commission.
customize-search-results-wordpress
Article by Tom Ewer WPExplorer.com guest author
28 Comments
  1. Danne · 11 years ago

    The problem is that the search function in WordPress, doesnยดt work so god and needs improvement! I usually add the Google custom search widget.

    • AJ Clarke · 11 years ago

      I agree, Google custom search is way better. That says have a look at our search results page, I’ve customized it quite a bit to make it more useful ๐Ÿ˜‰

  2. arth1992 · 11 years ago

    hey you have design bug in your site . When browser is minimized the tabs in “About the Author” section get disappeared except the “Bio” tab. (y)

    • AJ Clarke · 11 years ago

      This isn’t a bug, these secondary tabs are hidden via CSS on purpose so the design looks better on mobile devices.

  3. Seth James · 11 years ago

    Great blog, thanks! Question: at the moment entire pages are shown in my search results. Is there a way to just display the first paragraph? Many thanks

    • AJ Clarke · 11 years ago

      Hi Seth,

      Yes you can change this easily, but the display of the search page is based on your theme settings so it’s an adjustment you’ll need to make in your child theme and there is no way for me to tell you how because every theme is coded differently. You might have to hire a freelancer for this tweak ๐Ÿ˜‰

  4. Danny Mayer · 10 years ago

    Any suggested plugins for custom google search for global multisite search?

  5. Stefan Bols · 10 years ago

    Hey. Great post, which is now bookmarked. The post gives some great insights in which thoughts is important for a developer, who’s developing something search related of course. But also how to keep users on you site.

    All in all, thank you for this great blog post!

    And btw, nRelate Related Content is unfortunately not available anymore ๐Ÿ™

    Best regards,
    Stefan Bols
    Denmark

    • Kyla · 10 years ago

      Oh no – nRelate was a great free plugin ๐Ÿ™ Thanks for the heads up!

  6. Sara Leonard · 8 years ago

    Search plugin is definitely required for better search features. I have Implemented ‘searchIQ’ recently on a client’s website and it’s super cool. The features provides great search experience and analytics data.

  7. bdollar · 7 years ago

    How did you get the “Filter Results By” section above the search results on this site?

    • Kyla · 7 years ago

      Our website is completely custom, and hand coded by AJ (our founder, dev & WordPress guru) ๐Ÿ™‚ But I do think plugins like FacetWP you can use to easily add more search options/filters to your website.

  8. igster · 7 years ago

    Hmmm, I can’t seem to paste the code properly here …but it’s exactly as provided in #1 above.

    • Kyla · 7 years ago

      Make sure you are pasting it in the correct file and also that you don’t have double php tags.

  9. Hanna · 6 years ago

    Anyone knows how to display product tag title and description when searching for that specific product tag?
    To clarify: I have Woocommerce product tags and Ajax search premium. When you search for a word, I want to show the tag title and description above the results, if there is any ๐Ÿ™‚

    • Kyla · 6 years ago

      If you’re using Ajax Search Pro (by wpdreams) then they have this doc on how to show your category and taxonomy titles in search results. If that doesn’t work, then definitely try reaching out to the developer. If you’ve purchased a premium plugin support is often included for the first 6-12 months, so hopefully they can help!

  10. Laura Rodd · 6 years ago

    Thank you for sharing, it’s a great post! Customizing the search page is one of the biggest concerns for web designers. When it comes to WordPress, you need to modify your search page template in order to customize your search results. I’d like to add up some more details that can help web designers easily customize their search page in WordPress, hope you find it useful as well ๐Ÿ™‚

  11. Bill · 6 years ago

    this was an awesome help for optimizing my site for my readers. Thank you

  12. Sayed · 5 years ago

    Great article, I just used the search bar on my website and only received results for posts (not pages). How can you fix this?

    Thank you

    • AJ Clarke · 3 months ago

      By default WordPress search displays results from all post types and pages. If your site is only displaying standard posts it means your theme or an installed plugin has code built-in to exclude pages from your search results.

  13. Tawna · 4 years ago

    #3 is no longer available since 2019 … not sure why it is listed if the post was updated in March 2020?

    • Kyla · 4 years ago

      Thanks so much – I’ve removed the plugin. Often times our posts are updated for a small fix (like correcting a broken link) and not a full re-write which is why that plugin was still listed.

  14. ian · 4 years ago

    How are you designing this site’s results page? Is it one of those plugins you mention? If so, which one? Can’t for the life of me figure out how to get a nice looking results page.

    • Kyla · 4 years ago

      We use a custom theme that AJ designed, but any good theme should include a style search page. Alternatively I believe most search results plugins like Relevanassi use the same post styling as the blog. So I would suggest start by finding a theme you love and go from there!

  15. Augusto Marsal · 2 years ago

    My search page isn’t showing images, i’d like to show…

    • AJ Clarke · 3 months ago

      This is going to be a theme related issue. You can switch to a different theme that allows images on the search page or contact the theme developer for the theme you are using to request help. If you are using our Total theme you can create a custom template for your search page with the exact design you want!

  16. Mae · 1 year ago

    Thank you! I will take note of the tips!
    I recently encounter an issue with a search bar in WordPress. Great thing! Plug-ins saved me! ๐Ÿ˜
    Can I ask what would be the next process to do to show ALL the results on a page? Ivory search is what I used because it is compatible with the Astra theme. I am using Elementor in building the website in WordPress.

    Hope you can give me ideas if the search result page is must needed or if just plug-in will solve the problem. Thank you.

    • AJ Clarke · 1 year ago

      Hi Mae,

      The Ivory search plugin is used for more advanced searches and creating custom search forms, if your search results page is not showing ALL results it’s possible the issue is with the form itself. You’ll need to share the example URL so we can see what’s going on. That said, if you are using Elementor and Astra both of these support the native WordPress search function so unless you need advanced searching I wouldn’t recommend using the search plugin as it could just bloat things up with unnecessary code.

      The search widget in Elementor is part of their “Pro” plugin so it’s not available to free users but Astra does have a built-in search shortcode you can use anywhere like such “[astra_search style=”inline”]” – they have a useful guide in the Astra documentation here.

Leave a Reply

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

Learn how your comment data is processed by viewing our privacy policy here.