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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.