How can i set filter in view to display posts without relationship with the post where this view is shown?
Query filter section have only option to filter posts with relationship. In my case, i need to display post if don't have relationship.
Hi there,
Thank you for contacting us and I'll be happy to assist.
To filter out specific posts which have a relationship with the current post, you have a couple of options:
1. 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 and please let me know if you need any further assistance around this.
regards,
Waqar