How do I get my custom search to look for a specific piece of data within my custom metabox?

I have a custom search field and custom metabox for a custom post type.
The search field searches for my custom post type that uses the custom metabox rather than searching for the data within the custom metabox. I think my ‘value’ line is wrong and is causing it to pull up any custom post with values in the metabox rather than searching for the actual values. I’m just not sure what’s supposed to go there instead?

here is my code:

if (isset($_GET[‘lp_s_date’]) && !empty($_GET[‘lp_s_date’])){
$text = $_GET[‘lp_s_date’];

function me_search_query( $query ) {
if ( $query->is_search ) {
$meta_query_args = array(
array(
‘key’ => ‘prefix-mydates’,
‘value’ => $query->query_vars[‘s’] = ”,
‘compare’ => ‘LIKE’,
),
);
$query->set(‘meta_query’, $meta_query_args);
};
}
add_filter( ‘pre_get_posts’, ‘me_search_query’);
$args = array (
‘post_type’ => ‘listing’,
‘posts_per_page’ => -1,
‘s’ => $text,
‘exact’ => true,
‘sentence’ => true
);
}

Read more here:: How do I get my custom search to look for a specific piece of data within my custom metabox?

Leave a Reply

Your email address will not be published. Required fields are marked *