Hi. I’d like to modify the below code to only display upcoming (younger than the current date) events from my “Custom Post Type Events” in a Wordpress widget. At the moment it shows one of all event entries randomly.
This task is beyond my limited beginners PHP knowledge.
This is the date format I am using: j. M Y
<h2 style="margin-bottom:10px; margin-top:5px; color:#6b6b6b; text-align:left;">Veranstaltung:</h2>
<?php
$args = array(
'post_type'=>'events',
'orderby'=>'rand',
'posts_per_page'=>'1'
);
$events=new WP_Query($args);
while ($events->have_posts()) : $events->the_post();
?>
<?php the_field('f21_event_startdate'); ?>
<h2><a style="color:#1e73be;" href="<?php the_permalink() ?>"><?php the_title(); ?></h2>
<div style="margin-top:10px; margin-bottom: 10px;"><?php the_post_thumbnail('full'); ?></div></a>
<b><?php the_field('f21_event_sub_header'); ?></b>
<?php
endwhile;
wp_reset_postdata();
?>