Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. ***** for functions.php *****
  2.  
  3. // custom pagination
  4.  
  5. function custom_pagination($numpages = '', $pagerange = '', $paged='') {
  6.  
  7. if (empty($pagerange)) {
  8. $pagerange = 2;
  9. }
  10.  
  11.  
  12. global $paged;
  13. if (empty($paged)) {
  14. $paged = 1;
  15. }
  16. if ($numpages == '') {
  17. global $wp_query;
  18. $numpages = $wp_query->max_num_pages;
  19. if(!$numpages) {
  20. $numpages = 1;
  21. }
  22. }
  23.  
  24.  
  25. $pagination_args = array(
  26. 'base' => add_query_arg('paged','%#%'),
  27. 'format' => '',
  28. 'total' => $numpages,
  29. 'current' => $paged,
  30. 'show_all' => False,
  31. 'end_size' => 1,
  32. 'mid_size' => $pagerange,
  33. 'prev_next' => True,
  34. 'prev_text' => __('«'),
  35. 'next_text' => __('»'),
  36. 'type' => 'plain',
  37. 'add_args' => false,
  38. 'add_fragment' => ''
  39. );
  40.  
  41. $paginate_links = paginate_links($pagination_args);
  42.  
  43. if ($paginate_links) {
  44. echo "<nav class='custom-pagination'>";
  45. echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . "</span> ";
  46. echo $paginate_links;
  47. echo "</nav>";
  48. }
  49.  
  50. }
  51.  
  52.  
  53.  
  54.  
  55.  
  56. ****** css
  57. /* ============================================================
  58. CUSTOM PAGINATION
  59. ============================================================ */
  60. .custom-pagination span,
  61. .custom-pagination a {
  62. display: inline-block;
  63. padding: 2px 10px;
  64. }
  65. .custom-pagination a {
  66. background-color: @brown;
  67. color: @links;
  68. }
  69. .custom-pagination a:hover {
  70. background-color: @brightRed;
  71. color: @altWhite;
  72. }
  73. .custom-pagination span.page-num {
  74. margin-right: 10px;
  75. padding: 0;
  76. color:@white;
  77. font-weight:200;
  78. }
  79. .custom-pagination span.dots {
  80. padding: 0;
  81. color: gainsboro;
  82. }
  83. .custom-pagination span.current {
  84. background-color: @darkSubMeta;
  85. color: @altWhite;
  86. }
  87.  
  88.  
  89.  
  90. ******* for templates - make sure this is included before wp_reset_postdata(); and change the var from $multimedia to whatever your query was called.********
  91.  
  92. if (function_exists(custom_pagination)) {
  93. custom_pagination($multimedia->max_num_pages,"",$paged);
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement