Support

Account

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',
    ));}