Skip to content

Instantly share code, notes, and snippets.

@beaucollins
Forked from anonymous/events.php
Created June 8, 2011 21:16
Show Gist options
  • Save beaucollins/1015426 to your computer and use it in GitHub Desktop.
Save beaucollins/1015426 to your computer and use it in GitHub Desktop.
events.php
<?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'
)
)
)
);
?>
<?php 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 the_title(); ?>
<pre>
<?php print_r(array(meta('event-date'), $thedate)) ;?>
</pre>
<?php endif; ?>
</li>
<?php endwhile; endif; rewind_posts(); ?>
<?php endfor;
@beaucollins
Copy link
Author

Where is the meta function coming from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment