How to pass array into meta_query value with Advanced Custom Fields?

I am using Advanced Custom Fields plugin with WordPress. I am using relationship custom field.

    $posts = get_posts(array(
        'post_type' => 'slos_trainings',
        'meta_query' => array(
            array(
                'key' => 'lokacija', // name of custom field
                'value' =>  79,
                'compare' => 'LIKE'
            )
        )
    ));

I would like to pass array into meta_query value. Currently my code is working and it is returning all custom post types slos_trainings that have location custom meta field set to 79. But this field is a relationship, so it can have multiple ID-s. For example I want to find all posts with type slos_trainings that have lokacija set to 79 OR 200 OR 124, etc,..

Read More

How can I do this?

Related posts

Leave a Reply

1 comment

  1. $args = array(
        'post_type' => 'slos_trainings',
        'meta_query' => array(
            array(
                'key' => 'lokacija',
                'value' => array ( 79, 200, 124),
                'compare' => 'IN'
            )
        )
    );