Display custom post type taxonomy and month

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.

Read More

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

Related posts

Leave a Reply

1 comment

  1. Do a simple meta_query and compare by meta_value_num.

    array(
        'post_type' => 'webcast',
        'meta_key'  => 'webcast-date',
        'meta_value'    => array( time(), strtotime('+60 days') ),
        'meta_type'     => 'numeric',
        'meta_compare'  => 'BETWEEN',
        'orderby '  => 'meta_value_num',
        'order'     => 'ASC'
    );
    

    For an easy example. You can find more complex examples on the site filed under – even more if you combine that with a search for »meta_value_num date«.