Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

All age group conditions

$meta_query = array(
	'relation' => 'OR',
	array(
		array(
			'key'     => 'age_group_from',
			'value'   => '$ageMin',
			'compare' => '<=',
		),
	),
	array(
		array(
			'key'     => 'age_group_to',
			'value'   => '$ageMax',
			'compare' => '>=',
		),
	),
	array(
		'relation' => 'AND',
		array(
			'key'     => 'age_group_to',
			'compare' => 'NOT EXISTS',
		),
		array(
			'key'     => 'age_group_to',
			'compare' => 'NOT EXISTS',
		),
	),
);