Tell us what you are trying to do?
I need to add multiple filter options to a directory page so users can filter by multiple relationship posts.
Is there any documentation that you are following?
I've read many different pages of documentation but I just can't figure it out
We have a main Custom post type called HCCN (Health Center Controlled Networks). I've set up multiple other CPTs as many-to-many relationships, such that each HCCN may have a few of each of these relationships. I need the directory (archive) template to allow users to narrow down the archive results according to the relationships. I'm attaching a JPG of the design comp showing the filters on the left side.
What is the link to your site?
The directory/archive page is here:
hidden link
password: health
I have the Electronic Health Records filter working, but it doesn't allow me to add another relationship filter like it shows here: https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/
Also, I've converted the main HCCN single page, which shows all the data from the intermediary posts from relationships, to the block editor. But when I tried that for the HCCH archive page, it cleared everything out. So I went back to the older view style of editing the archive. I wonder if I'm going to have issues in the future if I don't convert the template to the new blocks editor? And does it have anything to do with getting the filtering by relationships to work? I saw this documentation, but it's using the blocks workflow: https://toolset.com/course-lesson/creating-a-custom-search/#2-6-filtering-posts-by-their-ancestors
Ugh.
Hello and thank you for contacting the Toolset support.
Currently, Toolset views cannot filter posts by more than ONE relationship. This is not supported yet. You can work around it with custom code, but that will require some programming skills. This can be leveraged in a way like:
- Custom code to generate the filters for secondary relationships.
- Custom code to hook into the query filter and augment the query using the Relationship API. Check this article https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/
Please note, that custom code, is out of the scope of this forum support. https://toolset.com/toolset-support-policy/
This does not mean that we won't help, we'll still help you if you encounter any issues with the provided API. If you are not comfortable with PHP programming, consider hiring a developer. Check our partners' page https://toolset.com/contractors/
I wonder if I'm going to have issues in the future if I don't convert the template to the new blocks editor?
No, we still support legacy views. We do encourage our users to switch to the block experience though.
And does it have anything to do with getting the filtering by relationships to work?
Both legacy and blocks view should work the same way. If you encounter any issues with any of them, open a new forum thread or chat session and we'll help with it.
Hi Jamal, thanks for your response. The link for augmenting the query makes sense in theory, how do I go about creating the filter on the front end to allow users to filter down by the other relationships?
Thanks,
Michelle
Also - where do I put the query code exactly? I think we can figure this out, but any hints on these things would really help.
With appreciation,
Michelle
Hello Michelle and my apologies for the late reply, I do not work on Sundays and Mondays.
how do I go about creating the filter on the front end to allow users to filter down by the other relationships?
The straightforward way is to create a custom shortcode that will generate the control filter for the other relationships. Then you can put the shortcode in the filters section if you are using the legacy views, or in a shortcode block if you are using the blocks editor.
Check WordPress documentation about creating shortcodes https://codex.wordpress.org/Shortcode_API
where do I put the query code exactly?
You can put the custom code in Toolset->Settings->Custom code, or in the theme's functions.php file, or in a separate/new plugin which will need to be activated.
Thank you for your help. We will address this in another round of development and may need more help at that time.