Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. <?php
  2.  
  3. //$previous = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
  4. //$next = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', false);
  5.  
  6. global $the_query;
  7.  
  8. if (get_query_var('paged')) {
  9. $current = get_query_var('paged');
  10. } elseif (get_query_var('page')) {
  11. $current = get_query_var('page');
  12. } else {
  13. $current = 1;
  14. }
  15. //==========================Pagination==============================
  16.  
  17. if(isset($the_query)){
  18. $total = $the_query->max_num_pages;
  19. if ($the_query->max_num_pages > 1) { // if we have more than 1 page
  20. if ($GLOBALS['wp_rewrite']->using_permalinks()) {
  21. $pl_args['base'] = user_trailingslashit(trailingslashit(get_pagenum_link(1)) . 'page/%#%/', 'paged');
  22. }else{
  23. $pl_args['base'] = '';
  24. }
  25. }else{$total = 1;}
  26.  
  27. if ($current > 0 && $current - 1 > 0) {
  28. $prev = $current - 1;
  29. } else {
  30. $prev = $current;
  31. }
  32.  
  33. if ($current < $total && $current + 1 <= $total) {
  34. $next = $current + 1;
  35. } else {
  36. $next = $current;
  37. }
  38. if ($total == $current) {
  39. $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>';
  40. } else {
  41. $next_link = '<a class="next link" href="' . str_replace('%#%', $next, $pl_args['base']) . '">'.sprintf(__('previous %s', 'aptheme'),$post->post_type).'.</a>';
  42. }
  43. if ($current == 1) {
  44. $prev_link = '<a class="prev link innactive" href="' . str_replace('%#%', $prev, $pl_args['base']) . '">'.sprintf(__('next %s', 'aptheme'),$post->post_type).'.</a>';
  45. } else {
  46. $prev_link = '<a class="prev link" href="' . str_replace('%#%', $prev, $pl_args['base']) . '">'.sprintf(__('next %s', 'aptheme'),$post->post_type).'.</a>';
  47. }
  48.  
  49. ?>
  50.  
  51. <nav class="pagination post-pagination">
  52.  
  53. <div class="pagination-wrapperers">
  54.  
  55. <?php if(isset($the_query->max_num_pages) && $the_query->max_num_pages > 1){ ?>
  56. <div class="controls-wrap">
  57.  
  58. <?php if ($next_link) { ?>
  59. <?php echo $next_link;?>
  60. <?php } ?>
  61. <?php if ($prev_link) { ?>
  62. <?php echo $prev_link;?>
  63. <?php }?>
  64. </div>
  65. <?php } ?>
  66.  
  67. </div>
  68. </nav> <!-- end .pagination -->
  69. <?php }else{
  70. $previous = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
  71. $next = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', false);
  72.  
  73.  
  74. ?>
  75. <nav class="pagination post-pagination">
  76.  
  77. <div class="pagination-wrapper">
  78.  
  79. <div class="controls-wrap">
  80. <?php if ($next) { ?>
  81. <a href="<?php echo get_permalink($next->ID); ?>" class="next link">
  82. <?php echo sprintf(__('previous %s', 'aptheme'),$post->post_type); ?>
  83.  
  84. </a>
  85. <?php } else { //} ?>
  86. <span class="prev link innactive">
  87. <?php echo sprintf(__('previous %s', 'aptheme'),$post->post_type); ?>
  88. </span>
  89. <?php } ?>
  90.  
  91. <?php if ($previous) { ?>
  92. <a href="<?php echo get_permalink($previous->ID); ?>" class="prev link">
  93. <?php echo sprintf(__('next %s', 'aptheme'),$post->post_type); ?>
  94.  
  95. </a>
  96. <?php } else { ?>
  97. <span class="next link innactive">
  98. <?php echo sprintf(__('next %s', 'aptheme'),$post->post_type); ?>
  99. </span>
  100. <?php } ?>
  101.  
  102. </div>
  103.  
  104. </div>
  105. </nav> <!-- end .pagination -->
  106. <?php }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement