I have a WP-query that should show up to 20 posts of future events. The posts should be only from the post-format-aside and should be ordered by the date. That part works quite well. What does not work, that is to exclude events that have already passed. ( ‘compare’ => ‘>=’, or ‘meta_compare’ => ‘>=’, don’t work. 🙁 )Could anybody tell me, where is my mistake?

Thanks a lot!

Here is my code:


$current_month = "";

setlocale(LC_ALL, 'de_DE@euro'); // Monatsnamen auf Deutsch ausgeben

$args = array( 'showposts' => 20,
                'cat' => array  
                'meta_key' => 'datumsfeld',
                'orderby' => 'meta_value',
                'compare' => '>=',
                'tax_query' => array(
                                        'taxonomy' => 'post_format',
                                        'field' => 'slug',
                                        'terms' => 'post-format-aside',

$myQuery = new WP_Query( $args   );
while ($myQuery->have_posts()) : $myQuery->the_post();

$datefield = DateTime::createFromFormat('Ymd', get_field('datumsfeld'));
        $month = $datefield->format("m");
        $year = $datefield->format("Y");

        if($month != $current_month){
            echo '<div class="abstand"><strong>'.strftime("%B %Y",$datefield->getTimestamp()).'</div></strong>';
            $current_month = $month;

Read more here: How to list only future events in a WP_query?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: