delarge
7/2/2018 - 10:29 PM

Using meta_query and date in WP

$meta_query = array(
	array(
		'key' => 'event_start_date',
		'value' => date('Ymd'),
		'type' => 'DATE',
		'compare' => '>='
	)
);

$args = array(
	'post_type' => 'post',
	'posts_per_page' => $posts_per_page,
	'order' => 'DESC',
	'orderby' => 'meta_value_num',
	'meta_key' => 'event_start_date',
	'offset' => (max(1, get_query_var('paged')) - 1) * $posts_per_page,
	'meta_query' => $meta_query
);