Created
June 8, 2011 21:04
-
-
Save anonymous/1015396 to your computer and use it in GitHub Desktop.
events.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$today = date("o-m-d"); | |
$future = strtotime ( '+6 days' , strtotime ( $today ) ) ; | |
$future = date ( 'o-m-d' , $future ); | |
$event_query = new WP_Query( | |
array( | |
'post_type' => 'event', | |
'meta_key' => 'event-date', | |
'orderby' => 'meta_value', | |
'order' => 'asc', | |
'meta_query' => array( | |
array( | |
'key' => 'event-date', | |
'value' => array($today,$future), | |
'compare' => 'BETWEEN', | |
'type' => 'DATE' | |
) | |
) | |
) | |
); | |
for ($i=0; $i<7; $i++){ | |
$thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ; | |
$thedate = date ( 'o-m-d' , $thedate ); ?> | |
<li> | |
<?php echo $thedate; | |
// loop thru all posts and check $thedate against your date meta | |
// and output if it matches | |
// then rewind_posts(); to set it up for the next day?> | |
<?php if (have_posts()) : while (have_posts()) : the_post();?> | |
<?php if(meta('event-date') == $thedate) {?> | |
<?php the_title(); ?> | |
<?php } else { ?> | |
<?php } ?> | |
</li> | |
<?php endwhile; endif; rewind_posts(); ?> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment