Support

Account

Home Forums General Issues get_posts, filtering by acf date field Reply To: get_posts, filtering by acf date field

  • Try adding this:

    'order'          => 'DESC',
    'orderby'        => 'meta_value',

    Or if you don’t plan on adding more meta_query params, this format may work too:

    $replaceme = get_posts([
        'posts_per_page' => -1,
        'post_type'      => 'custom_post_type',
        'meta_key'       => 'custom_field_name',
        'meta_compare'   => '>=', // optional
        'meta_value'     => 'custom_field_value',
    ]);

    I also don’t know the exact syntax but just play with it until it works. 🙂