You can save the following code snippet to your theme as archive-mc_event.php
as a starting point to add a vertical list of events to your theme.
functions.php
Filter the main query to order your events by start date.
// Query filters before the first WP Query function xdgp_filter_main_query($query = false) { // Bail if not home, or not a query, or on the admin section if (!is_a($query, 'WP_Query') || ! $query->is_main_query() || is_admin()) { return; } // Return events in site search if (is_search()) { $query->set('post_type', array('post', 'page', 'mc_event')); } // Modify queries on event list layouts if ( is_post_type_archive('mc_event') || is_tax('mc_season') || is_tax('mc_series') || is_tax('xdgp_genre')) { $query->set('nopaging', true); $query->set('posts_per_page', -1); // Include Vague Dates in Event List pages $query->set('meta_query', array( 'relation' => 'AND', 'first_date_exists' => array( 'key' => 'first_date', 'compare' => 'EXISTS', 'type' => 'NUMERIC' ), 'last_date_clause' => array( 'key' => 'last_date', 'value' => time() - (60*60*4), 'compare' => '>', 'type' => 'NUMERIC' ), )); $query->set('meta_key', 'first_date'); $query->set('orderby','meta_value_num'); $query->set('order', 'ASC'); } // Note the we aren't returning anything. We're modifying the query directly. } add_action('pre_get_posts', 'xdgp_filter_main_query', 99,1);
archive-mc_event.php
<?php if (have_posts()) { global $wp_query; // Load all event data into the query // By default, Groundplan filters any event WP_Query to remove closed events, and to sort them in ascending order by start date. // Event Sale status is loaded into $post->status if (function_exists('xdgp_load_all')) { xdgp_load_all(array('query' => $wp_query, 'connections' => true, 'connection_meta' => true, 'connected_post_meta' => true, 'mc_attachments' => false)); } // Filter out Unscheduled Events from this list foreach ($wp_query->posts as $key => $post) { if (($post->use_vague_dates == 'on')) { unset($wp_query->posts[$key]); } } } // Load the best Ticket URL for the situation to reduce user clicks. If a single performance, load the performance Ticket URL $post->ticket_url = xdgp_event_general_ticket_url($post); // Create the Buy Button based on event logic. // Default is .hidden-xs, replace that class for different formats. if (!empty($post->ticket_url) && $post->status != 'closed' && $post->status != 'sold-out') { $buy_button_html = '<a href="'.$post->ticket_url.'" class="btn">Get Tickets</a>'; } else if ($post->status == 'sold-out'){ $buy_button_html = '<a class="btn ">'.$post->sold_out_message.'</a>'; } // Optimize Title length (Optional) if (!empty($post->short_title)) { $title = $post->short_title; } else { $title = get_the_title(); } //endif; if (have_posts()) { global $post; foreach($wp_query->posts as $key => $post) { // Event Summary ?> <article <?php post_class('summary-mc_event'); ?>> <div class="image"> <?php $event_list_image = get_field('calendar_image', $post->ID); ?> <img src="<?php echo $event_list_image['url'] ?>"> </div> <header> <h2 class="entry-title"> <a href="<?php echo get_permalink($post->ID); ?>"> <div class="title"> <?php echo $title; ?> </div> <div class="byline"> <?php echo $post->byline; ?> </div> </a> </h2> <h4 class="dates"> <?php echo $post->display_dates_long; ?> </h4> </header> <div class="entry-summary"> <p> <?php echo (!empty($post->short_desc)) ? $post->short_desc : ''; ?> </p> <p> <?php echo str_replace('hidden-xs', 'visible-xs-inline-block', $buy_button_html) ; ?> <a class="btn" href="<?php echo get_permalink($post->ID); ?>">Read More</a> </p> </div> </div> </article> <?php // End Event Summary } }