Exclude old posts before “TODAY”
-
Good day,
I’m doing an events calender and need to dynamically exclude event posts that are older then TODAY via a custom value (not the actual wordpress post date, the custom value date).
Any ideas? My code so far…:
<h2>Upcoming Events</h2> <?php $lastposts = get_posts('category_name=events&meta_key=edate&orderby=meta_value&numberposts=3&order=asc'); foreach($lastposts as $post) : setup_postdata($post); ?> <div class="newsitem" onclick="location.href='<?php the_permalink() ?>';"> <div class="overlay" title="Click to read more about this event."></div> <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3> <p>Date: <?php $key="edate"; if(get_post_meta($post->ID, $key, true)){ echo get_post_meta($post->ID, $key, true); } ?><br />Location: <?php $key="elocation"; if(get_post_meta($post->ID, $key, true)){ echo get_post_meta($post->ID, $key, true); } ?></p> </div> <?php endforeach; ?>
I guess i’m in need of some ‘if’ + ‘AND’ to get posts only between *NOW* and the future (like year 2097 or something 🙂 …)
But how….? My date format for the custom field is YEAR-MOTH-DAY, i.e. 2009-10-31.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Exclude old posts before “TODAY”’ is closed to new replies.