Quick Tip: Add excerpts to search results page

If you’ve tried searching for a keyword on a WP site, you may have noticed that the search results don’t always include an excerpt of matching page(s). While you’re at it, have you tried the search function on your site? The missing excerpt is not WordPress’s fault, in reality the theme designer neglected or chose not to include that feature in the theme.

Here’s how to quickly add an excerpt to your search results page by hacking your theme. Important: make sure you have a copy of your original theme and/or backup the existing search.php page ready to restore in case you get in trouble. We’re not responsible if you muck up your site.

In WordPress admin, select Appearance -> Editor -> Search.php (screenshot below) Add the following tag after the end of the headline tag, usually </h2>:

<?php the_excerpt(); ?>

And hit “Save” and go try a search on your site!

the_excerpt_wordpress_code.jpg

Another tip, now that you’ve improved it with excerpts,  why not improve it further by trying Relevanssi plugin? Relevannsi will help bump up the quality of matching results. You’ll still need to  do a bit of work tagging your posts or pages but it’s worth it.

Another search plugin for power search: Relevanssi

If you need something a lot more powerful than Better Search, check out Relevanssi (Finish for Relevance). It installs just like any other WP plugin but when you take a look at the control panel, it is truly mind boggling.

It even has a Google style “do you mean” search suggestion as well as Fuzzy matching so it helps users find results better. Like Better Search you can log your visitors’ searches. You can also exclude certain words from being included.

I have decided to give it a whirl here on this site versus Better Search. Let’s see how it does.