Support » Fixing WordPress » Excluding Pages From Search Results

Viewing 3 replies - 1 through 3 (of 3 total)
  • For this i’m using Search Unleashed plugin.

    There’s a great tutorial here.

    In short, just add this to your theme’s functions.php file (or create the file if it doesn’t exist):

    <?php
    function mySearchFilter($query) {
    if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    
    add_filter('pre_get_posts','mySearchFilter');
    ?>

    I’d be very interested to know how to combine the page exclude function above with the ability to exclude posts by tag. I’m guessing there’s a simple solution?

    Cheers James – that’s brilliant – taken me ages to find it, such a simple solution!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluding Pages From Search Results’ is closed to new replies.