Home › Forums › ACF PRO › Relationship Using WP_Query arguments › Reply To: Relationship Using WP_Query arguments
Hi @cultivate,
Thanks for the post.
In this use case, I would recommend you make use of a conditional block to check if there is any value from the get_field() and then run the query.
The code would look like so:
// get only first 3 results
if(get_field('conference_talks'){
$ids = get_field('conference_talks', false, false);
$query = new WP_Query(array(
'post_type' => 'conferences',
'posts_per_page' => 3,
'post__in' => $ids,
'post_status' => 'any',
'orderby' => 'rand',
));}
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.