public
Last active

A page template that lists venues with Event Organiser

  • Download Gist
venue-page.php
PHP
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
<?php
/**
* Template Name: Venue Archive
* Description: A page template that lists venues with Event Organiser. Just a simple example of what
* you can do.
* @link http://www.stephenharris.info/2012/taxonomy-archives-and-venue-pages-in-event-organiser/ Related Tutorial
*
* You can add this to your theme and then create a page, selecting it as the page template. The 'content' you enter is ignored, but you could edit this to include that too.
*/
 
get_header(); ?>
 
<div id="primary">
<div id="content" role="main">
 
<?php
$venues = eo_get_venues();
if( $venues ):
foreach( $venues as $venue ):
 
//IMPORTANT: Make sure venue ID is an integer (If its a string, it will be interpreted as a slug).
$venue_id = (int) $venue->term_id;
 
printf('<article id="venue-%d">', $venue_id );
 
/* Display venue name and address */
echo '<header class="entry-header">';
printf('<h1> %s </h1>', eo_get_venue_name($venue_id) );
 
$address = array_filter(eo_get_venue_address($venue_id));
echo implode(', ',$address);
echo '</header>';
 
/* Display venue description & map */
echo '<div class="entry-content">';
echo eo_get_venue_description($venue_id);
echo eo_get_venue_map($venue_id);
 
/* Display next 5 events */
$events = eo_get_events(array(
'numberposts'=>5,
'event_start_after'=>'now',
'tax_query'=>array(array(
'taxonomy'=>'event-venue',
'field'=>'id',
'terms'=>array($venue_id),
))
));
if( $events ){
echo '<h2> Next 5 events </h2>';
echo '<ul>';
foreach ($events as $event ){
printf('<li> %s on %s </li>', get_the_title($event->ID), eo_get_the_start('jS F Y', $event->ID,null,$event->occurrence_id));
}
echo '</ul>';
}
 
echo'</div>';
echo'</article>';
 
endforeach;
endif;
?>
</div><!-- #content -->
</div><!-- #primary -->
 
<?php get_footer(); ?>

Hi,
this was really useful to me, but I have two questions:
1. How can I make this page template have the right sidebar and venues layout in two columns?
2. how can I make the title of the next 5 events linked to the event itself?
Thank you

I've worked out how to make point 1 still cant figure out point 2. any help?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.