custom WordPress Events Manager event tag archive page
Using the Events Manager WordPress plugin at work, I noticed that the event tag archive pages showed only current and upcoming events with a given tag. I wanted them to show all events, including past events, with the tag. I made a custom loop to accomplish this, within the Genesis framework. Create a file called taxonomy-event-tags.php in your Genesis child theme:
taxonomy-event-tags.php
1 2 3 4 5 6 7 8 9 |
<?php /** * This file adds the Taxonomy - Event Tags template to our Child Theme. */ /* Template Name: Taxonomy - Event Tags */ remove_action('genesis_loop', 'genesis_do_loop'); // remove genesis loop add_action('genesis_loop', 'event_tag_custom_loop'); // add the special loop |
Then include your event_tag_custom_loop
function at the bottom of this file.
event_tag_custom_loop function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<?php global $wp_query; $term = $wp_query->get_queried_object(); $loop = new WP_Query(array( 'post_type' => 'event', 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'event-tags', 'field' => 'tag_ID', 'terms' => array($term->term_id) ) ), // Order by event start date, most recent at the top 'meta_key' => '_event_start_date', 'orderby' => 'meta_value', 'order' => DESC )); ?> <div class="events-tag-archive-list"> <?php while ($loop->have_posts()) : $loop->the_post(); $custom_fields = get_post_custom($post->ID); $event_start_date = $custom_fields['_event_start_date'][0]; ?> <div id="post-<?php the_ID(); ?>" class="event post type-post"> <h2 class="entry-title"> <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent link to <?php the_title(); ?>"> <?php the_title(); ?> </a> </h2> <div class="post-info"> <span class="date event-start-date"> Event begins <a href="/link-to-your-events-page/<?php echo $event_start_date; ?>" title="View events on this day"><?php echo $event_start_date; ?></a> </span> <?php edit_post_link('Edit', '(', ')'); ?> </div> <div class="entry-content"> <?php the_excerpt(); ?> </div> <div class="post-meta"> <span class="tags"> <?php the_terms($post->ID, 'event-tags', 'Tags: ', ', ', ' '); ?> </span> </div> </div> <?php endwhile; ?> </div> |
Then you can call genesis()
after your function.
comments powered by Disqus