Filter collapse option?

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #41450
    Ranker
    Ranker
    Participant

    Hi, I would like to know if there is any way to collapse the filter settings. See image attached or link: https://werkenbij.mybrand.nl/vacatures-testpagina/

    #41465
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    By default there is no option to enable that, however it should be possible via a bit of custom code and some custom CSS.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter('wp_footer', 'asp_my_custom_script', 10);
    function asp_my_custom_script() {
      ?>
      <script>
      jQuery(function($) {
        $('.asp_ss fieldset>legend').on('click', function(){
    		$(this).closest('fieldset').toggleClass('asp_filter_opened');
    	});
      });
      </script>
      <?php
    }

    Apply this code to your theme custom CSS field (if it supports it) or use the custom CSS field on the search plugin back-end.

    .asp_ss fieldset legend {
        cursor: pointer;
    }
    
    .asp_ss fieldset div.asp_option {
        display: none !important;
    }
    
    .asp_ss fieldset.asp_filter_opened div.asp_option {
        display: flex !important;
    }

    This will hide the settings by default, and open them once the user clicks on the header of the filter.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41476
    Ranker
    Ranker
    Participant

    Wow! That does the trick Ernest. Is there a way to online open the first layer option “locatie” and close the others?

    Thanks again mate!

    PS: Would be a great feature to add in the plugin.

    • This reply was modified 1 year ago by Ranker .
    • This reply was modified 1 year ago by Ranker .
    • This reply was modified 1 year ago by Ranker .
    #41489
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you, it will be definitely added in a later release 🙂

    I think that is also possible, try chaning the first recommended code to:

    add_filter('wp_footer', 'asp_my_custom_script', 10);
    function asp_my_custom_script() {
      ?>
      <script>
      jQuery(function($) {
        $('.asp_ss fieldset>legend').on('click', function(){
    		$(this).closest('fieldset').toggleClass('asp_filter_opened');
    	});
        $('.asp_filter_cf_locatie legend').trigger('click');
      });
      </script>
      <?php
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41501
    Ranker
    Ranker
    Participant

    Works! Thank you for the great support.

    #41506
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.