Created
October 16, 2012 22:34
-
-
Save stephenh1988/3902494 to your computer and use it in GitHub Desktop.
A page template that lists venues with Event Organiser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); ?> |
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
Hi,
this was really useful to me, but I have two questions:
Thank you