Changing the pagination
-
Hello
I have the following problem:
I want to change the pagination for my calendar.
I know where to change it in the plugin folder (em-functions.php) and when I change it, it works. However, this is not the proper way to do it because then every update of EM will override the changes.So I’ve been trying to change it with mu-plugins (this is new for me).
I’ve made a mu-plugins folder in my wp-content with a em-functions.php file in it.The content is:
<?php function em_paginate($link, $total, $limit, $page=1, $pagesToShow=10){ if($limit > 0){ $url_parts = explode('?', $link); $base_link = $url_parts[0]; //Get querystring for first page without page $query_arr = array(); parse_str($url_parts[1], $query_arr); unset($query_arr['page']); unset($query_arr['pno']); $base_querystring = build_query($query_arr); if( !empty($base_querystring) ) $base_querystring = '?'.$base_querystring; //calculate $maxPages = ceil($total/$limit); //Total number of pages $startPage = ($page <= $pagesToShow) ? 1 : $pagesToShow * (floor($page/$pagesToShow)) ; //Which page to start the pagination links from (in case we're on say page 12 and $pagesToShow is 10 pages) $placeholder = urlencode('%PAGE%'); $link = str_replace('%PAGE%', $placeholder, $link); //To avoid url encoded/non encoded placeholders //Add the back and first buttons $string = '<div class="navigation">'; $string .= ($page>1 && $startPage != 1) ? '<a class="prev page-numbers" href="'.str_replace($placeholder,1,$link).'" title="1">1</a> ' : ''; if($page == 2){ $string .= ' <a class="prev page-numbers" href="'.$base_link.$base_querystring.'" title="2">«</a> '; }elseif($page > 2){ $string .= ' <a class="prev page-numbers" href="'.str_replace($placeholder,$page-1,$link).'" title="'.($page-1).'">«</a> '; } //Loop each page and create a link or just a bold number if its the current page for ($i = $startPage ; $i < $startPage+$pagesToShow && $i <= $maxPages ; $i++){ if($i == $page){ $string .= ' <strong><span class="page-numbers current">'.$i.'</span></strong>'; }elseif($i=='1'){ $string .= ' <a class="page-numbers" href="'.$base_link.$base_querystring.'" title="'.$i.'">'.$i.'</a> '; }else{ $string .= ' <a class="page-numbers" href="'.str_replace($placeholder,$i,$link).'" title="'.$i.'">'.$i.'</a> '; } } //Add the forward and last buttons $string .= ($page < $maxPages) ? ' <a class="next page-numbers" href="'.str_replace($placeholder,$page+1,$link).'" title="'.($page+1).'">»</a> ' :' ' ; $string .= ($i-1 < $maxPages) ? ' <a class="next page-numbers" href="'.str_replace($placeholder,$maxPages,$link).'" title="'.$maxPages.'">'.$maxPages.'</a> ' : ' '; $string .= '</div>'; //Return the string return apply_filters('em_paginate', $string); } } ?>Doing this, removes the pagination all together, allthough the functions seems to be read (if I put “echo ‘hello world’;” in it, it shows hello world).
Can somebody help me please?
Thx!
The topic ‘Changing the pagination’ is closed to new replies.