Date Query Builder
Date ranges, rolling windows and calendar parts — with the column, timezone and off-by-one boundary gotchas called out before they bite.
Shape of the range
Either an absolute date or a strtotime phrase — "1 January 2026", "-30 days", "last monday". Leave one empty for an open-ended range.
Inclusive boundaries
Includes the after and before dates themselves.
Oldest first
Order ASC, the right default for an events list.
no_found_rows
Skips the COUNT query when you are not paginating.
A secondary query with a loop that prints a real time element.
// Generated with WP CodeKit — powered by GrowQuest (https://growquest.io). $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 10, 'date_query' => array( array( 'after' => '2026-01-01', 'before' => '2026-06-30', 'inclusive' => true, ), ), ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { echo '<ul>'; while ( $query->have_posts() ) { $query->the_post(); printf( '<li><a href="%1$s">%2$s</a> <time datetime="%3$s">%4$s</time></li>', esc_url( get_permalink() ), esc_html( get_the_title() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); } echo '</ul>'; wp_reset_postdata(); } else { esc_html_e( 'Nothing in that range.', 'mytheme' ); }