[Resolved] Comparing Post Date with Current Date and Displaying Upcoming Events
I have a sidebar widget that will display upcoming events (Posts categorized as events). I only want to show events that are occurring today or in the future and have them order by soonest to latest.
However, I can’t seem to figure out how to have these events display properly. I tried a bunch of solutions I found through Google, but it is still not working. Can someone help?
Here’s the code:
<?php global $post; $args = array('category' => 9, 'numberposts' => 4,'orderby' => 'date','order' => 'ASC',); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <?php $postDate = get_the_date(); $todaysDate = date('j F Y'); if ( $postDate > $todaysDate | $postDate = $todaysDate) : ?> <li><a href="<?php the_permalink(); ?>" style="font-size:11px;"><span style="font-weight:bold;color:#afaca5"><?php the_time('n/j'); ?>:</span> <?php the_title_attribute(); ?></a></li> <?php endif; ?> <?php endforeach; ?> </ul> <br />
- The topic ‘[Resolved] Comparing Post Date with Current Date and Displaying Upcoming Events’ is closed to new replies.