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)