Hello everyone, I need to filter a relationship field by post object, I want the relationship field to show the posts that have the same id of post object field with the current post, I tried this code, but it’s not working. Can anyone tell me what’s wrong with this code?
I have a two post types, the first one is ‘chapters’, and the second id ‘novel’. in the’post’ post type I have a post object field that displays the novels of ‘novel’ post type. and I have a relationship field in the ‘chapters’ post type, and I want to filter the results of relationship field to display the chapters that have the same novel in post object field. I hope I explained my problem good.
There isn’t anything that will allow you to filter a relationship field based on a selection made in another field. The value of the other field is not available for the acf/fields/relationship/query/ filter, it is not supplied by ACF when it runs the AJAX request to get the posts.
There are a couple of possibilities.
1) is that you must save the post before you can filter based on this other field. Then in your filter that you posted above