• Hey,

    I was wondering if anyone knows how to add a search filter to the functions.php in my theme to filter “the_content” out of my search results.

    What I’m wanting is for people to only get a posts title in the results.

    I have the category filter and it works well. How do I go about filtering the_content?

    Thanks a bunch,

    Chris.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter recogn1ze

    (@recogn1ze)

    <?php
    function SearchFilter($query) {
    if ($query->is_search) {
    $query->set('cat','-9,-417');
    }
    return $query;
    }
    add_filter('pre_get_posts','SearchFilter');
    ?>

    This is the function I have to exclude categories from showing in the search results.

    Just trying to exclude the content from being searched or atleast turning up in the results.

    Thread Starter recogn1ze

    (@recogn1ze)

    Can this be done? Or does anyone have a link to a site where there maybe more info on this type of function?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to search filter to the content?’ is closed to new replies.