Include the Post Content in the Search Results

The post content is normally not included in the search results, but this is something you can easily change by adding a few lines of code to the functions.php inside your active theme folder.

The first thing you have to do is add the line below to the functions.php. This will make sure the post content data is included in the returned search data and is accessible under the ‘description’ key.

The next thing you have to do is include the ‘description’ data in the search results template.

The code below shows you how to do this with the wpsl_listing_template filter. The ‘description’ data is included on line 26 – 28. Copy the code below, and also place it in the functions.php

If you’re already using a custom search results template, then just include line 26 – 28 in your existing template code to make the post content show up.

Do make sure to flush the transient cache after you added the above code to the functions.php . You can do this on the WPSL settings page -> Tools section.