For future reference:
I am using the great Meta Box Plugin to help expedite meta box creation for my custom post types.
To build a highly customizable events section closely resembling a traditional calendar like
get_calendar creates, but for a specific custom post type.
— By relying solely on using Wordpresses built in time parameters, I am able to return my posts in an ASC order similar to a traditional calendar but I am limited to only showing posts up to the current day since there is no way to query and return scheduled posts - this is an issue obviously since I need to display ALL event posts for the current month, and onward...
— Additionally, I also need to be able to page to "previous" and "upcoming" months similar to
My Solution Thus Far:
— Due to the time parameter restrictions, I've opted to return my posts via
meta_key parameter instead and assigned it to my events "startdate" field, and then orderby -
This seems to replicate the same functionality Im after for the most part but now I'm posed with a serious issue of:
"how do i treat this meta value just like wordpresses native time parameters so that I can store this data appropriately for each month and have the option to page through the months similar to the get_calendar archive?"
Hopefully I was definitive enough in my explanation to help anyone who reads this make sense of it all. If not, please let me know and I will happily attempt to further clarify whatever it is...and thank you for the help!
Pasted below is my current "Calendar/Events" template as well as a screenshot of how it will most likely look on the front end.
<?php /* Template Name: Calendar */ ?> <?php get_header(); ?> <!-- featured_images.php --> <?php include ('featured_images.php'); ?> <div id="full_col"> <h2 class="feed_title_full"><?php wp_title('', true); ?></h2> <div id="calendar_nav"> <h4 id="current_month"><?php the_time( 'F Y' ); ?></h4> </div> <ul id="calendar"> <?php $current_year = date('Y'); // Get current YEAR ?> <?php $current_month = date('m'); // Get current MONTH ?> <?php $calandar_posts = new WP_Query( array( 'post_type' => 'calendar', 'year' => $current_year, 'monthnum' => $current_month, // Show ALL posts for current Month 'meta_key' => 'epr_startdate', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'posts_per_page' => -1, 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, )); ?> <?php if($calandar_posts->have_posts()) : while($calandar_posts->have_posts()) : $calandar_posts->the_post(); ?> <li class="calendar_entry"> <a href="<?php the_permalink(); ?>" class="calendar_link" title="<?php the_title_attribute(); ?>"></a> <div class="entry_date"> <?php echo get_post_meta($post->ID, 'epr_startdate', TRUE); ?> </div> <div class="shadow_overlay"></div> <?php the_post_thumbnail('calendar-teaser', array('class' => 'calendar-teaser-img', 'alt' => 'View Event')); ?> </li> <?php endwhile; else: ?> <h2>No Events for the month of <?php the_time( 'F' ); ?></h2> <?php endif; ?> <?php wp_reset_query(); ?> </ul> </div> <?php get_footer(); ?>