Edit 3
Now, combine Edits 1 and 2:
'date_query' = > array(
array(
'before' = > strtotime( get_the_date() ),
'inclusive' = > true,
)
)
Edit 2
You don’t have your inclusive
parameter inside the correct array.
Change this:
'date_query' = > array(
array(
'before' = > get_the_date()
),
'inclusive' = > true,
)
…to this:
'date_query' = > array(
array(
'before' = > get_the_date(),
'inclusive' = > true,
)
)
Edit
The get_the_date()
function must be used inside the loop, because it relies on the $post
global.
The get_the_date()
function also returns a date-formatted string, but the date_query
before
parameter accepts a strtotime()
compatible string.
Instead of this:
'before' => get_the_date()
…try this:
'before' => strtotime( get_the_date() )
Original Answer
The inclusive
parameter is part of the WP_Query()
date_query
parameter, and must be used inside of the array passed to date_parameter
. Refer to the example usage in the Codex:
$args = array(
'date_query' => array(
array(
'after' => 'January 1st, 2013',
'before' => array(
'year' => 2013,
'month' => 2,
'day' => 28,
),
'inclusive' => true,
),
),
'posts_per_page' => -1,
);
$query = new WP_Query( $args );