Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Filter collapse option?
- This topic has 5 replies, 2 voices, and was last updated 3 years, 3 months ago by
Ernest Marcinko.
-
AuthorPosts
-
February 19, 2023 at 2:07 am #41450
Ranker
ParticipantHi, 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/
February 20, 2023 at 1:25 pm #41465Ernest Marcinko
KeymasterHi!
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.
February 20, 2023 at 4:33 pm #41476Ranker
ParticipantWow! 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.
February 21, 2023 at 11:27 am #41489Ernest Marcinko
KeymasterThank 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 }February 21, 2023 at 6:16 pm #41501Ranker
ParticipantWorks! Thank you for the great support.
February 22, 2023 at 1:51 pm #41506Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.