Skip Navigation

[Resolved] Trying to display custom posts in taxonomy view by cat then sub-cat

This support ticket is created 4 years, 8 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 5 replies, has 2 voices.

Last updated by Chris 4 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#1308263

I have a custom post type and a hierarchical custom taxonomy (called categories here for convenience).

How can I display a list of all the top level categories (eg hidden link) as links to the sub-categories (eg hidden link) and each sub-category is a listing of the posts in that sub-category?

Fairly used to using Toolset but I can't seem to get this done.

Many thanks

Chris

#1308551

I think your goal's solution is here:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

You'd create some nested Views, and nest the View where you query Terms with Parent as set in the Parent View, into the one View where you list Terms that have no Parent.
So you'll get a list of Parent Terms, and for each, the child Terms (where you can again nest a View that displays the posts of those terms if you want)

Now, I am confused on your requirement's description though. You mention "How can I display a list of all the top level categories (eg hidden link)"[...]
This is simple, you create a View, list Taxonomies and add a Query filter that says "Parent is: None". This View will now produce in the Loop only Terms that have no parent (top level).

But later you mention "[...]as links to the sub-categories (eg hidden link)".
This is not possible, how would you link one parent term to many child terms? Since there are many Child Terms belonging to one parent each that is not possible.

Or you mean, to link to a list of all those child terms?
That is possible by creating a view that takes the same rules as before, but the Query Filter for the parent term will say "Parent is the taxonomy selected by the parent Taxonomy View".
This parent View would actually be the View with all Parent Terms (or a View where you just list one single parent term)

Please let me know if I misunderstood you, and if the solution provided does work for you.

#1308617

Thank you

You have understood correctly - I do want a link to a list of child terms.

This is what I want - on page 1 there is a list of links to states, then when I click on a state I get a list of cities (ie child terms of states) then when I click on the city I get a list of the posts in that city....

Am i listing taxonomies, posts what about the archive...??

Page 1 has a taxonomy view with 'Select taxonomy terms whose parent is None' and loop containing [wpv-taxonomy-link] - you can see that here hidden link

But what should be in that taxonomy archive that is linked to. Either I get multiple lists of posts/terms or all the posts in that archive but I just want the child terms...

I am completely confused by this. It seems like it should be simple but I just can't get it working...

I can provide login details if you want

#1308623

I understand.

The main issue here is, Toolset Views doesn't allow to query Terms in a View by URl parameter where you could pass a parent term, for example.
That is what's required to make this goal easily achievable, but its a new feature that would need to be requested here first https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Now, we could maybe work around this, with some Custom Code that alters the View's Query, depending on an URL parameter that tells us the "Parent" Term ID.

For this, you'd create a View that has all Parent Terms listed.
Each of the terms in the loop should link to the same page passing the Term ID as a ?term_id URL parameter.
In another view where you list child terms, you'd set the view to return terms that are a child to (and choose any).
Then, in a https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query you could alter that query, and make it listen to the URL parameter term_id, so the view returns only terms that are a child to that one passed in the URL parameter.

Then, a 3rd View is linked from the second View, listing the posts in that term (this is again possible with a URL attribute set in the link, and a filter listening to it in the 3rd Post View).

Please let me know if you'd need some setup examples on this, we could work on this together on a testing site if you have one.

There is no archive involved so far because archives cannot be filtered by "parents" or child terms.

#1308625

OK thank you - I'll find another way...

#1308627

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.