I am using a custom query to generate my search results. The code I am using works perfectly without the meta_query variables in my arguments array.
I am trying to compare multiple custom fields with ‘LIKE’.
References to $per_page
& $sort_by
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$per_page = ($_REQUEST['per_page']) ? $_REQUEST['per_page'] : 15;
$sort_by = ($_REQUEST['sort_by']) ? $_REQUEST['sort_by'] : 'best';
Array for query arguments:
$default = array(
's' => $search,
'paged' => $paged,
'post_type' => 'page',
'suppress_filters' => false,
'posts_per_page' => $per_page,
'meta_key' => '_wp_page_template',
'meta_value' => 'lois_product.php',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'lois_prodpage_colour',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'lois_prodpage_brand',
'value' => $search,
'compare' => 'LIKE'
)
)
);
Then I just call the arguments as you would expect..
$products = new WP_Query($default);
Loop through etc…
So as you can see… pretty simple stuff to be honest. I just cannot work out why it is returning 0 results as I know I have data to match specific terms or a combination..
This is for a custom WP ecommerce website which is integrated with an external EPoS System (I know)
Any help/pointers would be great!