initial filter from query var

Forums › Forums › Search & Filter Pro › initial filter from query var

Viewing 3 posts – 1 through 3 (of 3 total)
  • Anonymous
    #23222

    Hi,

    I have search and filter pro, it’s a wonderful plugin!

    I need to select the filter from the beginning with the value of ‘query var’ from another page.

    I’ve done this:

    
    $value = get_query_var('year');
    ....
    <script>
    $('input[value="<?php echo $value ; ?>"]').click();
    </script>
    

    But this method is far from ideal because first are charged all items then with click event the filter is activated.

    Is there a better method?

    Thanks

    Ross Moderator
    #23477

    Hmmm its not something I’ve tried yet (but will be a feature in the future), you could also look at preventing a submit happen

    So something using $('.searchandfilter').on("submit") and perhaps (e.stopEventPropogation()) only on the first submit (which is caused by your custom code)

    Thanks

    Anonymous
    #23630

    Something like this would be fantastic:

    $value = get_query_var('year');
    
    echo do_shortcode( '[searchandfilter id="131" metakey="year" value="'.$value.'"]'  ); 

    Then filter with post meta ‘year’ is activated at start with value from query var.

Viewing 3 posts – 1 through 3 (of 3 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.