• Resolved esp5466

    (@esp5466)


    Hello,
    We are looking for a Search plugin that would be setup only for one category excluding all the others.
    Can we achieve this with your plugin?
    Thank you.

Viewing 1 replies (of 1 total)
  • Kris

    (@c0nst)

    Hi @esp5466!

    Yes, you can do this with this code:

    add_filter( 'dgwt/wcas/search_query/args', function( $args ) {
    $args['tax_query'] = [
    [
    'taxonomy' => 'product_cat',
    'field' => 'slug',
    'terms' => ['category-slug'], // Set the category slug here
    'operator' => 'IN',
    ],
    ];

    return $args;
    } );

    You have two ways to add this code to your theme:

    1. Open the functions.php in your child theme and add the code at the end.
    2. or install the Code Snippets plugin and apply this code as a snippet.

    Best regards,
    Kris

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.