Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Hide Child Categories
- This topic has 8 replies, 2 voices, and was last updated 7 years, 11 months ago by
Ernest Marcinko.
-
AuthorPosts
-
June 28, 2018 at 9:09 pm #18502
diegomoreno
ParticipantHello
We want to see only the parent categories at the beginning, but when the parent category is selected then the child categories are visible. That’s possible?
We would also like to add a specific style for each child category, in order to change the color of the selection box to the color to which the category refers.
I am looking forward to your response.
June 29, 2018 at 2:37 pm #18509Ernest Marcinko
KeymasterHi,
Well, this might be possible with a custom script code. I have constructed a small custom code snippet, and placed it into the functions.php file in your child theme directory. This should hide the child checkboxes until they are checked. For reference, here is the custom code:
Please note that I cannot guarantee this is going to work with every single case, but it should do the trick in most of them.
Coloring the checkbox background could be possible via custom CSS. For example this will color the background of the category id = 1 to red:
[code]label[for$=termset_1] {
background-color: red !important;
background-image: none !important;
}[/code]You can use this as a template to create as many different colorings as you need.
I hope this helps!
June 29, 2018 at 3:41 pm #18512diegomoreno
ParticipantHi, thanks for your quick response.
I will make other configurations regarding this and in case of needing any help I will let you know. Good work in your support.
July 3, 2018 at 3:56 pm #18573diegomoreno
ParticipantGreetings. I hope you are well.
I need a little more of your help.
I have the filter configuration options ready as it should behave.
But I would like that when a parent category is selected, the children are not automatically selected, I would like to add a link only to select all the child categories.
I would also like that when a child category is selected, the parent category is selected.
(Example in the attached GIF)
July 4, 2018 at 2:48 pm #18588Ernest Marcinko
KeymasterHi,
Well, to prevent the auto checking, and to check the parents, try this:
Please note, that these qualify as customization requests, so I cannot guarantee any working solution.
July 4, 2018 at 4:19 pm #18589diegomoreno
ParticipantI placed the code in the functions.php but the behavior remains the same. What can I be doing wrong?
July 4, 2018 at 4:59 pm #18590Ernest Marcinko
KeymasterSorry about that, there was a mistake in the code. It should be ok now.
July 4, 2018 at 5:33 pm #18591diegomoreno
ParticipantOh, sir, excuse me. But it still does not work.
Remember the code we implemented earlier, which was to display the child categories when checking parents. Is interfering this?
Can you see again the .gif that I shared?
The point is that I want to be able to select the category “Azul” and “Por Color” and that the filter ignores those that are not selected.
If only the “Azul” category is selected and not its parent category, no results appear!. That’s the problem.
July 5, 2018 at 11:48 am #18601Ernest Marcinko
KeymasterHi,
Indeed, it was working on my console, but not as a separate script. I have made a few modifications to it, and placed it to the functions.php file in your theme child directory.
Please note, that this is probably not a full solution, but it should work in most cases.
For future reference, this is the modified code:
-
AuthorPosts
- You must be logged in to reply to this topic.