Grow your CSS skills. Land your dream job.

Multiple Custom Search pages

  • # October 3, 2012 at 3:31 pm

    How would I go about having 5 search pages on my site, each of which searches within a different category?

    I know I would use this in my functions.php if I wanted the search functionality on the whole site to only search specific categories.

    function SearchFilter($query) {
    if ($query->is_search) {
    // Insert the specific categories you want to search
    $query->set(‘cat’, ’8,9,12′);
    }
    return $query;
    }

    add_filter(‘pre_get_posts’,’SearchFilter’);

    Or is the answer to only return or echo the results from certain categories?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".