WordPress Search Filter – How to Exclude Pages from Search Results


Learn how to exclude pages from your WordPress search results and instead only show blog posts. By adding some code to our child theme, we can filter search results and only display posts.

Codes used:

if (!is_admin()) {
    function wpb_search_filter($query) {
        if ($query->is_search) {
            $query->set('post_type', 'post');
        return $query;


Related Posts

Leave a Comment

Sign up for Weekly Updates on our Most Read Blog Posts.