pagination on event list page
-
I would like to add pagination to the custom event list page.
so that the events page is not listed all in one page.
how can I do this? without calling search action?
thanks for your help.
-
I’ve tried the solution given in.
http://wordpress.org/support/topic/plugin-events-manager-pagination-location-insert-at-top?replies=16<?php
if( !empty($args[‘limit’]) && $events_count > $args[‘limit’] ){
//Show the pagination links (unless there’s less than $limit events)
$search_args = EM_Events::get_post_search() + array(‘page’=>’%PAGE%’);
$page_link_template = preg_replace(‘/(&|\?)page=\d+/i’,”,$_SERVER[‘REQUEST_URI’]);
$page_link_template = em_add_get_params($page_link_template, $search_args);
echo apply_filters(’em_events_output_pagination’, em_paginate( $page_link_template, $events_count, $args[‘limit’], $args[‘page’]), $page_link_template, $events_count, $args[‘limit’], $args[‘page’]);
}
?>but it give the url as /?page=pagenumber (/?page=2)
which leads to 404 page.
how can I modify this.
I tested by typing in /events/2/ and it still goes to 404 page.
how can I resolve this?
can I know what EM version you are using? and do you have a sample link for us to see?
also, have you tried something like [events_list pagination=1]
Hello agelonwi, thank you for quick reply as usual. :0
I am using the latest version Version 5.3.5. however, I had to make a events template separately due to split page formatting…first 3 on the returned events are formatted differently from the rest of the returned events (4-10).
my template script is as follows:
<?php
/*
Template Name: Events
*/
?><?
$showdetail = 4;
$i=0;
?><?php get_header(); ?>
<div id=”primary”>
<header>
<h1>EVENTS LIST</h1>
</header>
<div class=”content “><?php
$events = EM_Events::get( apply_filters(’em_content_events_args’, $args) );
$args[‘limit’] = “10”;
$args[‘pagination’] = “1”;
$args[‘page’] = (!empty($_REQUEST[‘page’]) && is_numeric($_REQUEST[‘page’]) )? $_REQUEST[‘page’] : 1;
$events_count = count($events);
$curevents = EM_Events::get( apply_filters(’em_content_events_args’, $args) );?>
<?php
if( $events_count > 0 ){?><?php foreach ($curevents as $EM_Event) : ?>
<?php $i++;//$EM_Event = em_get_event($post->ID, ‘post_id’);
$eventName = $EM_Event->output(‘#_EVENTNAME’);
//$eventName = $EM_Event->output(‘#_EVENTNAME’);
$eventLink = $EM_Event->output(‘#_EVENTLINK’);
$eventPageURL = $EM_Event->output(‘#_EVENTURL’);
$eventImage = $EM_Event->output(‘#_EVENTIMAGE’);
$eventDates = $EM_Event->output(‘#_EVENTDATES’);
$eventTimes = $EM_Event->output(‘#_EVENTTIMES’);
$locationName = $EM_Event->output(‘#_LOCATIONNAME’);
$locationfullline = $EM_Event->output(‘#_LOCATIONFULLLINE’);
$locationaddress = $EM_Event->output(‘#_LOCATIONADDRESS’);
$locationtown = $EM_Event->output(‘#_LOCATIONTOWN’);
$locationstate = $EM_Event->output(‘#_LOCATIONSTATE’);
$locationzip = $EM_Event->output(‘#_LOCATIONPOSTCODE’);
$webLink = $EM_Event->output(‘#_ATT{Web Link}’);
$venueID= $EM_Event->output(‘#_LOCATIONEXCERPT’);
$venueURL= get_permalink($venueID);
?><?php if ($i<$showdetail){?>
<div id=”post-<?php the_ID(); ?>” class=”events-event-box”>
“><?=$eventImage?>
<h2 class=”list-title”><?=$eventLink?></h2>
<h4 class=”eventlist-day”><?=$eventDates?></h4>
<h4 class=”eventlist-day”><?=$eventTimes?></h4><div class=”eventlist-content”>
” target=”_new”>Get Ticket
</div></div> <!– End post –>
<?}else{?>
<div id=”post-<?php the_ID(); ?>” class=”events-event-list”>
<div class=”date-col”>
<h4 class=”eventlist-day”><?=$eventDates?></h4>
</div>
<div class=”title-col”>
<h2 class=”list-title”><?=$eventLink?></h2>
</div>
<div class=”venue-col”>
” target=”_blank”><?=$locationName?>
</div>
<div class=”ticket-col”>
” target=”_new”>Get Ticket
</div>
</div><?}//endif?>
<?php?>
<div><?=$eventCategory?></div>
<?php endforeach; /* End loop */ ?>
<?php
if( !empty($args[‘limit’]) && $events_count > $args[‘limit’] ){
//Show the pagination links (unless there’s less than $limit events)
$search_args = EM_Events::get_post_search() + array(‘page’=>’%PAGE%’,’_wpnonce’=>$_REQUEST[‘_wpnonce’]);
$page_link_template = preg_replace(‘/(&|\?)page=\d+/i’,”,$_SERVER[‘REQUEST_URI’]);
$page_link_template = em_add_get_params($page_link_template, $search_args);
echo apply_filters(’em_events_output_pagination’, em_paginate( $page_link_template, $events_count, $args[‘limit’], $args[‘page’]), $page_link_template, $events_count, $args[‘limit’], $args[‘page’]);
}
?><?php }else{
echo get_option ( ‘dbem_no_events_message’ );
}
?>
</div><!– #content –></div><!– #primary –>
<?php get_sidebar(); ?>
<?php get_footer(); ?>hi,
sorry, quite confusing; maybe you can try pastebin.com to share codes; also, try to check events-manager/templates/templates/events-list.php for sample snippet on how to add pagination.
Thank you agelonwi, I’ve copied the pagination script from the link you gave me and the pagination is working. But pages above #2 returns no list to be listed
sorry. I’ve posted the codes here http://pastebin.com/aXDbhZbg
the pagination does work, but pages above #2 doesn’t return events to be listed.
do you have a sample link for us to see?
thank you agelonwl for your tip to use parts of events-manager/templates/templates/events-list.php. you were so correct.
as for the #2 returning no list, that was a logic error in my part.
the page offset shouldn’t have been $args[‘offset’] = ($args[‘page’]-1) * $args[‘limit’];but, $args[‘offset’]= ($args[‘page’] – 1) * $args[‘limit’] + 1;
Also, I took out all the $args that doesn’t seem to do anything…
$args[‘scope’]=’future’;
$args[‘orderby’]=’event_start_date,event_start_time,event_name’;
$args[‘order’]=’DESC,DESC,ASC’;
$args[‘pagination’] = true;I’m still trying to get the event order in ascending order, not descending. but at least the pagination is now working.
thank you agelonwl and marcus for your help.
- The topic ‘pagination on event list page’ is closed to new replies.