• Hi:

    I use Relevanssi on my site. Previously I had just a blog so I used the search widget on my sidebar such that with Relevannsi I was able to do a site-wide search.

    But now I have a membership site and a forum. For the membership site and forum I need to use two more separate search widgets, one for the category called “membership” and one for the category called “forums”.

    I have a separate sidebar for the membership pages, and a separate sidebar for the forum.

    Is it possible to use Relevanssi to achieve this?

    Use No. #1: For the whole site excluding “membership” and
    forum” category

    Use #2: For the “membership” category alone

    Use #3: For the “forum” category alone

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes, you can use as many widgets as possible, just add extra parameters to them to restrict the search.

    [searchform cat="membership"]

    [searchform cat="forum"]

    These would create search forms that only search one category. For the main search, I’d do it so that if no category setting is set, the membership and forum categories are then excluded. You can do that by adding this to your theme functions.php file:

    add_filter( 'relevanssi_modify_wp_query', 'rlv_exclude_cats' );
    function rlv_exclude_cats( $query ) {
        if ( ! $query->query_vars['cat'] || empty( $query->query_vars['cat'] ) ) {
            $tax_query = array(
                array(
                    'taxonomy' => 'category',
                    'field'    => 'slug',
                    'terms'    => array( 'membership', 'forum' ),
                    'operator' => 'NOT IN',
                )
            );
            $query->set( 'tax_query', $tax_query );
        }
        return $query;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Can I use 3 instances of the search widget using Relevanssi’ is closed to new replies.