Passing a variable containing a comma separated list of values in a meta-query

In WordPress meta queries, when using the ‘compare’ => ‘IN’ comparison, the value should be an array, not a string. When you manually input array( ‘1302’, ‘1329’ ), it works because it’s correctly formatted as an array. However, when using $artists_string_value, it’s treated as a single string, not an array of values.

You should modify your code to use the $artists_ids array directly in your meta query instead of converting it into a string. Your meta query should look like this:

'meta_query' => array(
  array(
    'key'     => 'release_artist_$_artist',
    'value'   => $artists_ids, // Use the array directly
    'compare' => 'IN'
  )
),

$artists_ids = array(); // Initialize an empty array to store artist IDs
if (have_rows('release_artist')): 
  while (have_rows('release_artist')): the_row();
    $artist = get_sub_field('artist');
    if ($artist) {
        $artists_ids[] = $artist->ID; // Add artist ID to array
    }
  endwhile; 
endif;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)