Hoping someone can help with this...
I've got a php variable called $comma_separated, that is a simple array.
<?php echo $comma_separated; ?>
This gives me as result like this:
'558927', '529306', '529227', '50921', '50923',
I'm trying to use this variable inside a meta_query argument for a WP_Query, like so:
$args = array (
'post_type' => 'properties',
'posts_per_page' => -1,
'paged' => $paged,
'meta_query' => array(
array(
'key' => 'property_code',
//this works
//'value' => array('558927', '529306', '529227', '50921', '50923',),
//this doesn't
'value' => array( $comma_separated ) ,
'compare' => 'IN',
),
),
$the_query = new WP_Query( $args );
I've tried adding the string as a value manually, which works fine, but I can't get the variable to work. Hopefully this is quit a simple fix, but can't seem to figure it out. Any help would be much appreciated.