Skip to content

Instantly share code, notes, and snippets.

@stephenh1988
Created October 16, 2012 22:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephenh1988/3902494 to your computer and use it in GitHub Desktop.
Save stephenh1988/3902494 to your computer and use it in GitHub Desktop.
A page template that lists venues with Event Organiser
<?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(); ?>
@ferrbea
Copy link

ferrbea commented Sep 12, 2013

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

@ferrbea
Copy link

ferrbea commented Sep 16, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment