Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Frontend>Categories> STOP auto select child terms when parents are selected
This topic contains 4 replies, has 2 voices, and was last updated by allchemist 3 years, 1 month ago.
- AuthorPosts
- February 2, 2021 at 12:00 pm #31406
Dear Ernest
I have this Ajax Search Pro Instance:
https://www.illuminatoren.com/downloads/Right in the sidebar you can see all categories & tags, they are grouped in parent categories with child terms. A single parent category can have many child terms, for example 20 child terms in one parent category.
I use Frontend Search Settings > Advanced > Logic Options: “All of the selected terms must match exactly, but unselected ones are not excluded“. Because of this I get NO search results, because all checkboxes are selected. So the user has to, for example (parent category: Bibelfiguren / Charaktere der biblischen Geschichten), uncheck 19 checkboxes manually if he wants just one child term and by mistake checked the parent category. Of course you can say it’s the users mistake and he has to deselect the parent category and then specifially select one single child term.
Is there an option to turn this auto checking child terms OFF? The present solution is useful fo Search Settings > Advanced > Logic Options: “At least one selected terms should match” but not for a very strict configuration as written above. I think all users with this strict configuration will be happy if it is possible to STOP the autoselect from all child terms.
On the single download-post you see in the sidebar right bottom a regular wordpress category archive with all parent categories and child terms:
https://www.illuminatoren.com/downloads/kopie-pa-test-halleluja/Thank you for your great help!
Kind regards from Switzerland, Luzern
February 2, 2021 at 2:39 pm #31410Hi,
I’m afraid this is not possible either. This is hard coded into the script files, which I do not recommend changing, as any of the future updates will simply override them and revert back any changes.
We are in a middle of a huge rework on the filters system, I could add a feature request to turn off this behavior.
You can try a custom code, although I don’t know if this will work in all of the cases:
add_action('wp_footer', 'asp_add_menu_stop_checkbox_parent_child'); function asp_add_menu_stop_checkbox_parent_child() { ?> <script> jQuery(function($){ $('*[data-lvl]').data('lvl', 'null'); }); </script> <?php }
This should remove the attribute which is used to recongize the parent-child structures.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 2, 2021 at 3:09 pm #31412Thank you for your answer. Your Custom Code works, I have put it in the Code Snippet plugin. The child terms are not selected anymore now. Great!
I highly recommend you to implement this function in the rework on the filter system, because this behaviour is a real problem if you want to precise, exact search for a parent category with many child terms, e.g. “shoe” as parent category and 30 child terms with different brands. Then the users have to uncheck ALL child terms if they just want to search for the parent category (Shoes)? Or did I get something wrongt?
I have got the impression that the site got a bit slow in reactions with the two modifications (first modification was here with Trigger Live Search: https://wp-dreams.com/forums/topic/how-trigger-live-search-after-custom-code-automatically-select-filter-values/). If you klick around a bit selecting different categories in the sidebar you can feel it. And this are just 8 (?) images, I wonder how it will be with 500 or 1000 images.
https://www.illuminatoren.com/downloads/kind regards
DaveFebruary 2, 2021 at 3:14 pm #31413I would not recommend displaying 500 or 1000 results at the same time, if you mean that. Displaying that amount of HTML and image assets at the same time will probably kill the users browser if they don’t have any amount of ram.
Best,
The suggested modification should not have any noticable effect on the overall perfromance though.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 2, 2021 at 3:36 pm #31415Dear Ernest
I will not display so many images at the same time, I will do pagination etc. but I just wonder how long the search process will take then with a huge database. But that’s not a question to answer now
OK, I trust you, maybe I was wrong with my impression. 🙂
- This reply was modified 3 years, 1 month ago by allchemist.
- AuthorPosts
The topic ‘Frontend>Categories> STOP auto select child terms when parents are selected’ is closed to new replies.