• Dear Members!

    I would like to ask for your help regarding a custom option.
    I managed to add my S&F (Search & Filter) filter to my code, and it seems to be working, as when I provide an incorrect ID, I receive the “No products found” message. However, my problem lies with the frontend filter, which, unfortunately, doesn’t seem to filter this custom query. The Display results method is set to Custom, and the URL is also correct.

    What did I do wrong?

    Thank you in advance!

    <?php
    echo do_shortcode('[searchandfilter id="18574"]');
    
    $search_filter = get_query_var('search_filter');
    $search_filter_id = 18574;
    
    $args = array(
        'post_type'   => 'product',
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'search_filter_id' => $search_filter_id,
        'search_filter_matches' => $search_filter,
    );
    
    $the_query = new WP_Query($args);
    
    if ($the_query->have_posts()) {
        ?>
        <ul class="products" id="test-grid">
            <?php
            while ($the_query->have_posts()) : $the_query->the_post();
                wc_get_template_part('content', 'product');
            endwhile;
            ?>
        </ul>
    <?php
    } else {
        echo __('No products found');
    }
    
    wp_reset_postdata();
    ?>
  • The topic ‘Front end Filtering issues’ is closed to new replies.