Can't get pagination to work with eo_get_events()

WordPress Event Management, Calendars & Registration Forums General Question Can't get pagination to work with eo_get_events()

This topic contains 2 replies, has 2 voices, and was last updated by  Stephen Harris 11 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5342

    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-&gt;ID). '"&gt;' .$event-&gt;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-&gt;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; ?&gt;
    

    <?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">&rarr;</span>' , 'eventorganiser' ) ); ?></div>
    <div class="nav-previous events-nav-newer"><?php previous_posts_link( __( ' <span class="meta-nav">&larr;</span> Newer events', 'eventorganiser' ) ); ?></div>
    </nav><!-- #nav-below -->
    <?php endif; ?>

    <?php endif; ?>

    haleeben
    #5343
    haleeben
    #5348

    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
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.