I am collecting values from a query string as an array. Then collecting those values and placing them into the value of the 'meta_query'.
I am having trouble where nothing gets outputted from the WP_Query. I feel like there is something wrong with the second array in the 'meta_query'.
I have tried to change the compare to 'LIKE', and that shows all the content instead of what is in the query.
Query string:
?variable[]=value1&variable[]=value2
PHP code:
<?php
$variable_selected = $_GET['variable'];
$filter = array(
'post_type' => 'my_custom_post_type',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'my_post_field',
'value' => $variable_selected,
'compare' => 'IN'
)
)
);
$posts = new WP_Query( $filter );
Any help on this will be great.