I have a set of fields in a repeater that in a group field.
I’m tring to search a name in that repeater from all the posts i have in “projects” custom post that attached to a specific “customer”
more_details – group field
professionals – repeater
professional_name – subfield which i need to search on
I tried this:
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'more_details_$_professionals_$_professional_name'", "meta_key LIKE 'more_details_%_professionals_%_professional_name'", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
$searchKey = $_POST['searchKey'];
$customerID = $_POST['customerID'];
$args = array(
'post_type' => 'projects',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'customer',
'compare' => '=',
'value' => $customerID,
),
array(
'key' => 'more_details_$_professionals_$_professional_name',
'compare' => 'LIKE',
'value' => $searchKey,
)
)
);
$query = new WP_Query( $args );
if( $query->have_posts() )....
group fields do not have indexes, the meta key should be
more_details_professionals_$_professional_name