Home › Forums › General Issues › Relationship query filter not working › Reply To: Relationship query filter not working
My question would be why are you letting users choose an unlimited number of post when you will only show 3? Is there some case where you’re going to show more than 3?
You can get the unformatted value of the field
$posts = get_field('relationship_field_name', false, false);
This will return just an array of post IDs and not have the overhead of getting many posts. Then you can use this array in your own WP_Query() to get the number of posts that you want using the “post__in” argument to only get posts that are included in the field and limit the query (posts_per_page) to 3. This is what ACF does when it formats the value except for the limit.
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.