• Resolved nilssondigital

    (@nilssondigital)


    Is there a button/widget/snippet that can be added to reset the filters/url? I got a jquery snippet to reset the filters, but since it doesn’t reset the URL, it doesn’t really work as all the filters are still applied, and re-apply when clicking a new one after resetting that way.

    Ideally for me the filters would show as url parameters (?age=6&height=123 etc) rather than pages/full URL string, as it’s an internal tool and will not be indexed by search engines. If this were an option, then the above would work because jqyuery can reset the parameters without redirecting the page….

    Anything like this possible?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support fesupportteam

    (@fesupportteam)

    Hi @nilssondigital

    For the reset button, there is this code example with a shortcode [reset_filters_button]:

    function reset_filters_button_shortcode() {
        if( class_exists( 'FilterEverything\Filter\UrlManager' ) ){
            $urlManager = new \FilterEverything\Filter\UrlManager();
            $resetUrl = $urlManager->getResetUrl();
    
            return '<button class="reset-filters-button"><a href="'.$resetUrl.'">Reset filters</a></button>';
        }
        return '';
    }
    add_shortcode('reset_filters_button', 'reset_filters_button_shortcode');

    OR

    To show the Reset button you can place the chips widget or shortcode [fe_chips] wherever you need and add the next example of CSS on the page with filtering.
    You can add it for example via Filters -> Settings -> Experimental -> Custom CSS:

    #wpc_chips_widget-2 .wpc-filter-chip:not(.wpc-chip-reset-all){
        display: none;
    }

    Where #wpc_chips_widget-2 is the chips widget wrapper and it may be different in your case. You can find it in HTML code. In general, this code hides all chips except the Reset button. But it will appear only when you apply some filters.

    There is no such possibility the filter is working only with the URL with the addition of URL prefixes, and it should remove the URL in order to remove all of the filters. Basically use the current page URL without all of those adiitions from filtering.

    Best Regards – Victor

    Thread Starter nilssondigital

    (@nilssondigital)

    Ah that’s perfect – I had no idea that’s what ‘Chips’ was. Kept seeing it referenced and tried looking it up bit didn’t know that is exactly what I needed. Thank you!

    One side note that would be helpful for those – I have several radio fields that are just ‘yes/no’ responses (true/false doesn’t work because I have to return the output somewhere else and it always comes out as 1/0), but an option to include the title for those so I know WHAT is yes or no…would be helpful. Very small request and I’m using this anyways so thank you!

    Plugin Support fesupportteam

    (@fesupportteam)

    Hi @nilssondigital

    If you need to add in chips some data to the values, you can use this simple code example:

    // Define the callback function for the 'wpc_chips_term_name' filter hook
    function modify_chips_term_name($term_name, $term, $filter) {
        $term_id = $term->term_id;
    
        if($term_id === 'min__price') {
            return $modified_term_name = $term_name . ' $';
        }
    
        if($term_id === 'max__price') {
            return $modified_term_name = $term_name . ' $';
        }
    
        return $term_name;
    
    }
    
    // Hook the callback function to the 'wpc_chips_term_name' filter hook
    add_filter('wpc_chips_term_name', 'modify_chips_term_name', 10, 3);

    Best Regards – Victor

    Thread Starter nilssondigital

    (@nilssondigital)

    That’s amazing thank you so much!

    One last question, not really related so can open a different ticket for it – is there plans for the Search function to support custom fields (ACF)? Right now it doesn’t seem to search that content, and based on what I read on the documentation it supports post content, title and taxonomies? This would be a GAME changer, as most of the data/posts I’m filtering through is based on custom fields.

    Thanks!

    Plugin Support fesupportteam

    (@fesupportteam)

    Hi @nilssondigital

    Yes, the development team has big plans for future updates in order to extend the search capabilities. We do not have any date on our hands when it can happen but we know that there are such plans.

    Currently, it is searching in the post title, content, short description, and SKU of Woo products.

    Best Regards – Victor

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Reset filters button?’ is closed to new replies.