Home › Forums › General Issues › Reverse Relationship Meta Query › Reply To: Reverse Relationship Meta Query
okay, how is it not working, is it returning unrelated posts or is it not returning any posts?
This line in your code
'value' => $post_id,
should be
'value' => '"'.$post_id.'"',
the double quotes are important, see the comment in your code. ACF stores a relationship field as a serialized array of post IDs as string values. Searching for just a 1 without quotes would return 1, 12, 21, 123, 312, 321, 67549145, anything with a 1 in the post ID. Also, a serialize array stores the length of the string, so it would also return all posts with a post ID whose string length contains the post ID that you are searching for.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.