Home › Forums › Calendar Products › Events Calendar PRO › pagination for current day list
- This topic has 5 replies, 3 voices, and was last updated 10 years, 1 month ago by
Support Droid.
-
AuthorPosts
-
March 16, 2016 at 1:31 pm #1089963
Niall
ParticipantIve 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
March 17, 2016 at 8:06 am #1090276Niall
Participantupdate,
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!
March 17, 2016 at 11:46 am #1090468Josh
ParticipantHey 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!
March 18, 2016 at 9:56 am #1091064Niall
ParticipantJosh, If this works I’ll name my first child after you. Thanks for the lead
March 21, 2016 at 7:20 am #1091746Josh
ParticipantHey Andrea,
Haha sounds good! If it’s a girl, Josey might be a good alternative 🙂
Thanks!
April 5, 2016 at 9:35 am #1098367Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘pagination for current day list’ is closed to new replies.
