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: lien caché
This isn't the first time I needed this kind of functionality, too (see here: lien caché), so any help in this matter would be greatly appreciated. Thanks in advance!
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
Great, thank you. I appreciate it.
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.
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.
So this is what I've been able to accomplish with a view in the term archives: lien caché
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.
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.
So it's really just a WordPress limitation than anything else? Bummer. Well, thanks for looking into this anyway. I appreciate the insight.