WordPress meta query with meta serialized data array value

Probably should have waited a bit but after posting the question I found a solution based on my points above and repeated here: https://codex.wordpress.org/Class_Reference/WP_Meta_Query https://generatewp.com/filtering-data-with-wp_meta_query/ My Solution: $metaSearchSubQuery = [ ‘relation’ => ‘OR’ ]; foreach($eventTypeId as $id) { $metaSearchSubQuery[] = [ ‘key’ => ‘EventId’, ‘value’ => serialize($id), ‘compare’ => ‘like’ ]; } $metaSearchQuery[] = $metaSearchSubQuery;

How to count items of meta query?

$query->found_posts may be what you are looking for from the code reference: https://developer.wordpress.org/reference/classes/wp_query/ Note that meta_query expects nested arrays, even if you only have one query. You may need to use: $meta_query[0][] = array( ….. You should also take care with the form of the original query. If there are one or more relations defined, … Read more

WordPress meta query not working

When using LIKE clause, you should be using % to the start and end of the value to make it match with the existing values. So your query should look like this. add_action( ‘pre_get_posts’ , ‘my_pre_get_posts’ ); function my_pre_get_posts( $query ) { $value=”%”.$_GET[‘s’].’%’; if( $query->is_main_query() && $query->is_search() ) { $query->set( ‘meta_query’, array( array( ‘key’ => … Read more