In this tutorial I’ll show you how to quickly restrict your WordPress search results to either Pages or Posts through a simple snippet of code in the functions.php file.

Using Child Themes to allow for future updates without losing your modifications.

Code Snippet:

function SearchFilter($query) {
if ($query->is_search) {
$query->set(‘post_type’, ‘post’);
return $query;


Free tutorials for WordPress, Slider Revolution and Visual Composer. New tutorials added every Wednesday.

Take your WordPress website and skills to the next level!



SUPPORT: Our website offers additional information and perks. Please check it out!

Enjoy this article and want more?

Why not join our weekly newsletter and we’ll let you know when we add more awesome Wordpress tutorials and articles?