Skip to content

Instantly share code, notes, and snippets.

@bagerathan
Created August 23, 2021 06:16
Show Gist options
  • Save bagerathan/5cb278f522a70d0ca323c8decf5d60fb to your computer and use it in GitHub Desktop.
Save bagerathan/5cb278f522a70d0ca323c8decf5d60fb to your computer and use it in GitHub Desktop.
[Posts from same month] #wp
$start_date = date( 'ym01' );
$end_date = date( 'ymt' );
$meta_query = array(
'key' => 'event_date',
'value' => array( $start_date, $end_date ),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
);
$args = array(
'post_type' => 'hh_event',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'event_date',
'order' => 'ASC',
'meta_query' => array( $meta_query )
);
$the_query = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment