Skip Navigation

[Resolved] in a view loop I would like to search parent taxonomy and hide child taxonomy

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 3 voices.

Last updated by Shane 2 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#2295517
taxonomy search (1).jpg

Hello I'm trying to add a search field in a view loop.
I've correct insert search field and search button and it works.
Now the problem is the custom field are too long and it's not clean to choose the currect value, so I would like to divide that with main category and sub category but when I show list in a category menu I see parent and child.
I'd like to use conditional field and after parent taxonomy is choosed, enable other field to choose child taxonomy
I'm trying to replicate this https://toolset.com/forums/topic/display-only-child-or-parent-of-a-taxonomy/ but it don't help me because I can't use search.
Could you help me?
Thank you
many regards

#2295647

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Can I clarify what you are aiming to do, so that we are talking about the same thing?

You want to have a View that shows posts, and include a taxonomy filter.

The taxonomy is hierarchical, e.g.

main-category-1
-- sub-category-A
-- sub-category-B
main-category-2
-- sub-category-C
-- sub-category-D
...etc.

You want to split the View filter so that the main category and sub-category are selected separately (you choose the main category, and then you have the option to choose only the relevant sub categories).

Is that an accurate description of what you want?

Because, if so, I'm afraid it's not possible.

You could achieve something like that, but you would need to write custom JavaScript to hide the actual filter input and create new virtual inputs that behaved in the way described above, and updated the hidden actual filter input as users made changes.

If you want to try that and get stuck we can give you some pointers, but we can't code that for you.

#2295815

Hi Thanks for your answer.
Yes your description is correct and I'm not so happy it's not possible.
Could you share some indication where I have to insert javascript to hide children subcategory?
Hope it's not so complicate

#2298967

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Fabio,

The custom javascript can be added in the JS section of your view.

When you scroll down to the Filter section editor there should be a tab called JS and there is another called CSS.

The JS section is where you will add the custom Javascript.

Thanks,
Shane

#2302049

Hello, thank for your answer,
I just ask if I need to use some function or it's enought to add code in javascript are you wrote to me.

#2302105

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Fabio,

It should be enough to add your custom javascript, however if you're performing an AJAX search in your view then you will need to add the appropriate callback function.

The correct one should be.

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.layout (object) The jQuery object for the View layout wrapper
	*/

// Custom code goes here
	
});

Additionally if you require the use of any other of our Callback functions then you can click on the Frontend Events button and insert the appropriate callback function.

Thanks,
Shane