I'm limiting my query to use show post from 6 months ago which works fine.
But I need it to be based on a date that is in the post_meta
table instead of 'post_date_gmt'.
In my case I have meta_keys are called payment_date
and the values are of course a date like 31-10-2016
for example.
$months_ago = 6;
$args = array(
'date_query' => array(
array(
'column' => 'post_date_gmt',
'after' => $months_ago . ' months ago',
)
),
'numberposts' => -1
);
Check it here: https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
If you scroll the examples, you'll see:
Display posts where the custom field key is a set date and the custom field value is now. Displays only posts which date has not passed.
$args = array(
'post_type' => 'event',
'meta_key' => 'event_date',
'meta_value' => date( "Ymd" ), // change to how "event date" is stored
'meta_compare' => '>',
);
$query = new WP_Query( $args );
In your case you could put something like: date( "dmY", strtotime( '6 months ago' ) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With