I'm building a custom search. On this i'm trying to get posts where the searched text should be used as a wild card to compare within 2 meta_key.
Below is my code,
<?php $args = (
array(
'post_type' => 'registration',
'meta_key'=>'rg_upload_video',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'rg_first_name',
'value' => $s,
'compare' => 'LIKE'
),
array(
'key' => 'rg_last_name',
'value' => $s,
'compare' => 'LIKE'
)
),
'posts_per_page' => 12,
'paged' => get_query_var('paged') ? get_query_var('paged') : 1 )
);
$loop = new WP_Query($args);
?>
As a result it's simply returning all posts having Meta_key as rg_upload_video. I need the posts having searched text in meta_key rg_first_name or rg_last_name.
Did anyone know where i'm going wrong ?
Try running the below code.