php - Inequality based on today's date and SCF date not working

admin2025-01-08  5

I have the following custom query and I would like to exclude any posts whose SCF dates are in the past. I have checked that the custom date of the post is returned in the Ymd format and it is. I can see that the custom query is correctly linked in Elementor since changing the DESC to ASC changes what posts are visible. I've also tried including 'type'=>'DATE' and 'type'=>'NUMERIC' in the meta_query and this has not changed the outcome.

function get_next_music_agenda($query) {
    $today = date('Ymd');
    $query->set('meta_key', 'music_month');
    $query->set('orderby', 'meta_value');
    $query->set('order', 'DESC');
    $query->set('meta_query', array(
        array(
            'key' => 'music_month',
            'compare' => '>=',
            'value' => $today
        )
    ));
}
add_action('elementor/query/get_next_music_agenda_query', 'get_next_music_agenda');
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736266797a1149.html

最新回复(0)