pagination for current day list

Home Forums Calendar Products Events Calendar PRO pagination for current day list

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1089963
    Niall
    Participant

    Ive created a very basic loop to display today’s events in a small section of my site’s homepage (index.php)

    WP_Query( array(
    ‘post_type’ => Tribe__Events__Main::POSTTYPE,
    ‘eventDate’ => $current_date,
    ‘eventDisplay’ => ‘day’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘tribe_events_cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => array(‘adults’),
    ‘operator’ => ‘NOT IN’
    )
    )
    ) );

    it works well but I was wondering if there was a way to create prev and next day pagination the would load on page via ajax?

    thanks in advance

    Andi

    #1090276
    Niall
    Participant

    update,
    Ive created a much sexier loop, so this is the function I’d like to add the pagination to:

    function do_easy_event_list() {
    	// Safety first! Bail in the event TEC is inactive/not loaded yet
    	if ( ! class_exists( 'Tribe__Events__Main' ) )
    		return;
    
    	// Has the user paged forward, ie are they on /page-slug/page/2/?
    	$paged = get_query_var( 'paged' )
    	? get_query_var( 'paged' )
    	: 1; 
    
    	// Build our query, adopt the default number of events to show per page
    	$upcoming = new WP_Query( array(
    		'post_type' => Tribe__Events__Main::POSTTYPE,
    		// 'paged'     => $paged,
    
    		'eventDate'    => $current_date,
    		'eventDisplay' => 'day',
    		'tax_query' => array(
    			array(
    				'taxonomy' => 'tribe_events_cat',
    				'field' => 'slug',
    				'terms' => array('adults'),
    				'operator' => 'NOT IN'
    				)
    			)
    		) );
    	
    	// If we got some results, let's list 'em
    	while ( $upcoming->have_posts() ) {
    		$upcoming->the_post();
    		$title = get_the_title();
    		$date  = tribe_get_start_date();
    		
    		// Of course, you could and probably would expand on this
    		// and add more info and better formatting
    		echo "<p> $title <i>$date</i> </p>";
    	}
    	
    	// Is Pagenavi activated? Let's use it for pagination if so
    	if ( function_exists( 'wp_pagenavi' ) )
    		wp_pagenavi( array( 'query' => $upcoming ) );
    
    	// Clean up
    	wp_reset_query();
    }
    
    // Create a new shortcode to list upcoming events, optionally
    // with pagination
    add_shortcode( 'easy-event-list', 'do_easy_event_list' );

    thanks!

    #1090468
    Josh
    Participant

    Hey Andrea,

    Thanks for reaching out to us here!

    Unfortunately something like this is a customization that is out of scope for what we’re able to provide support for here in our forums.

    However, looking at the code it looks like it is set up properly to handle pagination as well as appears to take advantage of the WP-PageNavi plugin. For this, this stackoverflow thread may be helpful in getting this loop set up for ajax loading the pagination here.

    Let me know if this helps.

    Thanks!

    #1091064
    Niall
    Participant

    Josh, If this works I’ll name my first child after you. Thanks for the lead

    #1091746
    Josh
    Participant

    Hey Andrea,

    Haha sounds good! If it’s a girl, Josey might be a good alternative 🙂

    Thanks!

    #1098367
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘pagination for current day list’ is closed to new replies.