Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Multiple Custom Search pages

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #40138
    slb535
    Member

    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)
  • The forum ‘Back End’ is closed to new topics and replies.