Hey Stephen
I’m trying to pagination to work just like on the category archives page but I’m using the eo_get_events() function and I can’t get it to work. Any tips?
Here is my code
12,'events_start_after'=>'today', 'showpastevents' => false));
if($events):
$return= '
Date/TimeEvent NameEvent Venue';
foreach ($events as $event):
//get the post content
$post_object = get_post( $event->ID );
$description = $post_object->post_content;
$date = eo_get_the_start( get_option( 'date_format' ), $event->ID,null,$event->occurrence_id );
$time = eo_get_the_start( get_option( 'time_format' ), $event->ID,null,$event->occurrence_id );
//Check if all day, set format accordingly
$date_time = ( eo_is_all_day($event->ID) ? ''. $date.'' : ''. $date .''.$time.'' );
$return .= '
' .$date_time. '<a>post_title. '" href="' .get_permalink($event->ID). '">' .$event->post_title. '</a>'.$description.'';
// check to make sure the event has a venue, if it doesn't it throws an error
if( $venue_id = eo_get_venue($event->ID) ){
$venue_name = eo_get_venue_name($venue_id);
$venue_link = eo_get_venue_link($venue_id);
$venue_address = eo_get_venue_address($venue_id);
$return .= ''. $venue_name .'' .$venue_address[address] .' '.$venue_address[city] .'';
}
endforeach;
$return.='';
echo $return; ?>
<?php
if ( $wp_query->max_num_pages > 1 ) : ?>
<nav id="nav-below">
<div class="nav-next events-nav-newer"><?php next_posts_link( __( 'Later events <span class="meta-nav">→</span>' , 'eventorganiser' ) ); ?></div>
<div class="nav-previous events-nav-newer"><?php previous_posts_link( __( ' <span class="meta-nav">←</span> Newer events', 'eventorganiser' ) ); ?></div>
</nav><!-- #nav-below -->
<?php endif; ?>
<?php endif; ?>
haleeben
Nope, pagination doesn’t work with eo_get_events()
. You need to use WP_Query
(accepts identical arguments).
Note, with a custom query like this you’ll want;
$event_query = new WP_Query( ... );
if( $event_query->max_num_pages > 1 ){
...
}
i.e. reference your local $event_query
not the global $wp_query
which is responsible for the ‘main query’ i.e. the actual page you’re on, not the event query inside it.
Stephen Harris