Support

Account

Home Forums Feature Requests Relationship Field: filter for posts (i.e. image) Reply To: Relationship Field: filter for posts (i.e. image)

  • Hi @nicmare,

    This is something you can hack using the acf/fields/relationship/query filter. This filter will allow you to modify the $args array used to query the posts. For instance, should you want to query only posts which have featured image set, then you could use the following code:

    add_filter('acf/fields/relationship/query', 'my_relationship_query', 10, 3);
    
    function my_relationship_query( $args, $field, $post ){
        
        $args['meta_query'] = array(
    
        	'key' => '_thumbnail_id',
            'compare' => 'EXISTS'
        );
    
        return $args;
    }

    For more info on this, have a look at