Custom Post Type/Custom Date Field Archive
-
I am using the following code (found here) to display my upcoming events/shows from the custom post type ‘shows’ ordered by custom date field ‘showdate’.
<?php $timecutoff = date("Y-m-d"); $args = array( 'post_type' => 'shows', 'orderby' => 'meta_value', 'meta_key' => 'showdate', 'meta_compare' => '>=', 'meta_value' => $timecutoff, 'order' => 'ASC' ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); $eventdate = get_post_meta($post->ID, "showdate", true); ?> <?php if(!isset($currentMonth) || $currentMonth != date("m", strtotime($showdate))){ $currentMonth = date("m", strtotime($showdate)); ?> <li><?php echo date("F", strtotime($showdate)); ?></li> <?php } ?> <ul> <li> <h5><?php echo $showdate; ?></h5> <h4><?php the_title(); ?></h4> <?php the_content(); ?> </li> </ul> <?php endwhile; else: ?> <ul id="shows"> <li><?php _e('No Events Scheduled! .'); ?></li> </ul> <?php endif; ?>
This outputs in the following format:
OCTOBER
Show
ShowNOVEMBER
Show
ShowI need to paginate this display by month so it shows
OCTOBER
Show
ShowNext Page – >
Then on the following page shows November, the next page December and so on.
Does anybody have any suggestions for how to achieve this?
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Custom Post Type/Custom Date Field Archive’ is closed to new replies.