Skip Navigation

[Resolved] Display Child Terms in Filters on Parent Term Archive Pages

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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2664737
screenshot2.png
screenshot1.png

I have taxonomy terms with multiple levels of child terms, and if the user is on a parent term archive page, I want the user to be able to filter their term search further by selecting a child term from the filters. With the way the filters display, if a user is on a parent term archive, it only shows the parent term in the filters, even when the child terms have posts associated with them. Assigning the posts to the parent, doesn't really help with this.

Regarding my attachments, screenshot1.png displays the general post type archive which displays a full list of all available terms. As you can see, the child terms under Mental Health Agencies have posts associated with them. I currently have this layout shared with the Services taxonomy archives, so when I visit a parent term archive page directly, the same filters only show that one parent term, and none of the children (see screenshot2.png), despite the posts associated with those children terms being displayed in the post loop output.

Please visit the Services archive page to see for yourself: hidden link

This isn't the first time I needed this kind of functionality, too (see here: hidden link), so any help in this matter would be greatly appreciated. Thanks in advance!

#2664901

Hi,

Thank you for contacting us and I'd be happy to assist.

Based on your report, I was able to reproduce the same behavior on my test website too. On taxonomy term archive, if same taxonomy's search field is included, it only shows the current term as option, and not other terms.
( not even the child terms )

I've shared these details with the development team for further review and will keep you updated through this ticket.

regards,
Waqar

#2665097

Great, thank you. I appreciate it.

#2665391

Thank you for waiting and I've heard back from the concerned team.

If you are on a taxonomy archive then the term of that taxonomy has already been pre-selected (by the underlying WordPress query). It has never been possible to show results for one taxonomy term on the archive of another taxonomy term.

For a case, where you do need to display options with other terms, the workaround would be to use a taxonomy View to generate the list of taxonomy term options, where each item links to the corresponding taxonomy term's archive. And then this view can be inserted in the search section of the archive, so that it appears like a part of the search. But, in reality, it will just be the links, taking visitors to other terms archive pages.

#2665507

Yeah, but the problem with a view is that it wouldn't be able to interact with the AJAX that automatically refreshes the view output to correspond with the user's selection. Additionally, having links to the individual archive pages is counter to the checkbox based design that I have in these post archives.

Sure they will "look" like filters, but they wouldn't necessarily act like it either, unless you have some other suggestions that involve URL parameters.

#2665611

So this is what I've been able to accomplish with a view in the term archives: hidden link

I made a view that replicates the filter form with checkboxes which submits URL parameters to the root CPT archive, presenting filtered results to the user. I did this because implementing a localized filter (made with a view that only outputs the current parent's children terms) on the term archive page didn't produce any favorable results (read: no change in the loop output).

This isn't ideal, because I'm basically forced to push the user back out of the term archive into the root post archive AND I have to display all filter selections for consistency, otherwise it's gonna be weird having limited selections initially, but submitting the filter adds more? That wasn't gonna fly, so I opted to show all filter selections no matter where the user was at.

This kinda works, but it's not the result I was hoping to accomplish. I'm still wondering if there's another way I can make this work.

#2665837

Thank you for sharing this update.

The workaround that you've implements is a closest possible match, all things considered.

Strictly technically speaking, in WordPress structure, the role of an individual archive is to limit to items based on the current categorization criteria.
( in this case a taxonomy term )

So if there is a requirement to provide means to search or navigate through other terms, an external search (like the view you've used) will be needed. I don't see any change introduced to this structure anytime soon, unless WordPress decides to introduce any change at the query level.

#2665865

So it's really just a WordPress limitation than anything else? Bummer. Well, thanks for looking into this anyway. I appreciate the insight.