I have created events as custom post types and I’m storing the event start date as a custom field (YYYY-mm-dd
). I’ve also assigned a taxonomy to each event.
I need to display a list of events by category in a single month.
The code below shows that I am currently able to display a list of events by the taxonomy 'bmx racing'
but I now need to display all the bmx racing events in any given month.
I need to work out how to take the month from the event start date (custom field) and apply it to this query.
<?php
query_posts( array(
'post_type' => 'event',
'event-category' => 'bmx racing'
'posts_per_page' => '-1',
'orderby' => 'date',
'order' => 'ASC',
) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<h3 style="color:#99cc00;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_content(); ?>
<?php endwhile; endif; wp_reset_query(); ?>
Any help is much much appreciated.
Thanks in advance
Do a simple
meta_query
and compare bymeta_value_num
.For an easy example. You can find more complex examples on the site filed under meta-query – even more if you combine that with a search for »meta_value_num date«.