I would like to filter a custom types post by posts who do not have a relationship with other specific post type
Is it possible?
Hi Meirk,
Thanks for asking! I'd be happy to help.
To filter out specific posts which have a relationship with another post, you have a couple of options:
1. If you're showing your posts through a view, you can create a custom shortcode that gets the ID of the post and checks it for a relationship using "toolset_get_related_posts" ( https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts ).
If a relationship is found the shortcode can return 'true" and if not it can return "false".
Next, you can use this shortcode in a condition to show or hide content from that specific post:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
2. Another option is to use a secondary view to generate a list of IDs for all those posts which are in a relationship and then use those IDs in "post__not_in" array to be excluded from your primary view's output.
https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
I hope these suggestions will help.
regards,
Waqar