0

I am running a meta query to pull out past custom post types (named 'show') between two dates.
The dates are any show between the 1st jan 2000 and 31st dec 2009

$end_2000s = '20091231';
$start_2000s = '20000101';
$row = 1;
$args = array(
    'post_type'             => 'show',
    'posts_per_page'        => -1,

    'meta_query'            => array(
        'relation'          => 'AND',
        array(
            'key'           => 'from_date',
            'compare'       => '>=',
            'value'         => $start_2000s,
        ),
        array(
            'key'           => 'from_date',
            'compare'       => '<=',
            'meta_value'    => $end_2000s,
        )
    ),

    'order'                 => 'ASC',
    'meta_key'              => 'from_date',
    'orderby'               => 'meta_value',
);

What I get is shows between 2000-01-01 and the date today (2019-02-11)

TIA.

Martin
  • 63
  • 2
  • 11
  • I can't see the usage of 2009-12-31 (20091231) in your code?? – jasie Feb 11 '19 at 11:56
  • The variable $date_now has value of '2010-01-01 00:00:00'. The date '2010-01-01 00:00:01' is greater than this. – Michas Feb 11 '19 at 14:46
  • Even changing it to a string '20100101' as thats what is stored in the database it still doesn't work. Updated to reflect current code being used. – Martin Feb 12 '19 at 12:04

0 Answers0