Answers for "wp query sort by meta date"

PHP
0

wp query sort by meta date

$args = array(
    'numberposts' => 2,
    'meta_query' => array(
        array(
            'key' => 'event_date', // I've set this variable according to your examples
            'value' => date("Y-m-d"),
            'type' => 'DATE',
            'compare' => '>=' // Or > if strictly bigger dates are required
        )
    )
);

// get results
$the_query = new WP_Query( $args );
Posted by: Guest on June-12-2020

Browse Popular Code Answers by Language