WordPress meta_query by compare (value, array, date)

Simple meta query options

=   equals
!=  does not equal
>   greater than
>=  greater than or equal to
<   less than
<=  less than or equal to

$MetaQuery[] = array(
	'key'     => 'metaname',
	'value'   => 'metavalue',
	'compare' => '>=',
	);

$args = array(
	'post_type'      => 'post',
	'post_status'    => 'publish',
	'meta_query'     => $MetaQuery
	)

 

Compare with multiple value

array(
	'key'     => 'metaneme',
	'value'   => array('value 1', 'value 2' ),
	'compare' => '='
	)

Compare BETWEEN

array( 
	'key' => 'price',
	'value' => array(20,30),
	'compare' => 'BETWEEN'
	)

Compare NOT EXISTS

array( 
	'key' => 'price',
	'compare' => 'NOT EXISTS'
	)

Compare DATE

$today = date( 'Y-m-d' ); // Date must in this format ('Y-m-d')
array(
	'key'     => '_expaires',
	'value'   => $today,
	'compare' => '>=',
	'type'    => 'DATE'
	)