Home › Forums › General Issues › Trouble with relationship query › Reply To: Trouble with relationship query
Thanks for all the info. Very clear!
As for the code. You will need to add in the ‘posts_per_page’ arg and set it to
This should fit the 5 post limit issue.
As for the code, it looks great.
If you turn the get_posts into a WP_Query, you can then debug the actual SQL. This will help to spot any issues in the SQL.
You can do this like so:
<?php $artworks = new WP_Query(array( 'post_type' => 'artworks', 'meta_query' => array( array( 'key' => 'artist', // name of custom field 'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234" 'compare' => 'LIKE' ) ) )); print_r($artworks); die;
Hope that helps
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.