Popular Categories

How to display post between two dates using custom query in WordPress?

Just few days back, i got one of the requirements for filter via date range. So to solve this, i used custom wordpress query to get the posts between the 2 dates. Here is the code for your reference:

$args = array(
‘date_query’ => array(
‘after’ => ‘January 1st, 2015’,
‘before’ => ‘December 31st, 2015’,
‘inclusive’ => true,
$query = new WP_Query( $args );

To view the Data Parameters, you can reference the WordPress Developer Documentation here: https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters