Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - <?php
 - //$previous = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
 - //$next = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', false);
 - global $the_query;
 - if (get_query_var('paged')) {
 - $current = get_query_var('paged');
 - } elseif (get_query_var('page')) {
 - $current = get_query_var('page');
 - } else {
 - $current = 1;
 - }
 - //==========================Pagination==============================
 - if(isset($the_query)){
 - $total = $the_query->max_num_pages;
 - if ($the_query->max_num_pages > 1) { // if we have more than 1 page
 - if ($GLOBALS['wp_rewrite']->using_permalinks()) {
 - $pl_args['base'] = user_trailingslashit(trailingslashit(get_pagenum_link(1)) . 'page/%#%/', 'paged');
 - }else{
 - $pl_args['base'] = '';
 - }
 - }else{$total = 1;}
 - if ($current > 0 && $current - 1 > 0) {
 - $prev = $current - 1;
 - } else {
 - $prev = $current;
 - }
 - if ($current < $total && $current + 1 <= $total) {
 - $next = $current + 1;
 - } else {
 - $next = $current;
 - }
 - if ($total == $current) {
 - $next_link = '<a class="prev link innactive" href="' . str_replace('%#%',in_same_cat, $next, $pl_args['base']) . '">'.sprintf(__('previous %s', 'aptheme'),$post->post_type).'.</a>';
 - } else {
 - $next_link = '<a class="next link" href="' . str_replace('%#%', $next, $pl_args['base']) . '">'.sprintf(__('previous %s', 'aptheme'),$post->post_type).'.</a>';
 - }
 - if ($current == 1) {
 - $prev_link = '<a class="prev link innactive" href="' . str_replace('%#%', $prev, $pl_args['base']) . '">'.sprintf(__('next %s', 'aptheme'),$post->post_type).'.</a>';
 - } else {
 - $prev_link = '<a class="prev link" href="' . str_replace('%#%', $prev, $pl_args['base']) . '">'.sprintf(__('next %s', 'aptheme'),$post->post_type).'.</a>';
 - }
 - ?>
 - <nav class="pagination post-pagination">
 - <div class="pagination-wrapperers">
 - <?php if(isset($the_query->max_num_pages) && $the_query->max_num_pages > 1){ ?>
 - <div class="controls-wrap">
 - <?php if ($next_link) { ?>
 - <?php echo $next_link;?>
 - <?php } ?>
 - <?php if ($prev_link) { ?>
 - <?php echo $prev_link;?>
 - <?php }?>
 - </div>
 - <?php } ?>
 - </div>
 - </nav> <!-- end .pagination -->
 - <?php }else{
 - $previous = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
 - $next = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', false);
 - ?>
 - <nav class="pagination post-pagination">
 - <div class="pagination-wrapper">
 - <div class="controls-wrap">
 - <?php if ($next) { ?>
 - <a href="<?php echo get_permalink($next->ID); ?>" class="next link">
 - <?php echo sprintf(__('previous %s', 'aptheme'),$post->post_type); ?>
 - </a>
 - <?php } else { //} ?>
 - <span class="prev link innactive">
 - <?php echo sprintf(__('previous %s', 'aptheme'),$post->post_type); ?>
 - </span>
 - <?php } ?>
 - <?php if ($previous) { ?>
 - <a href="<?php echo get_permalink($previous->ID); ?>" class="prev link">
 - <?php echo sprintf(__('next %s', 'aptheme'),$post->post_type); ?>
 - </a>
 - <?php } else { ?>
 - <span class="next link innactive">
 - <?php echo sprintf(__('next %s', 'aptheme'),$post->post_type); ?>
 - </span>
 - <?php } ?>
 - </div>
 - </div>
 - </nav> <!-- end .pagination -->
 - <?php }?>
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment