Advertisement
viktormorales

Funciones Wordpress: Paginador Nativo

Mar 11th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  // 1. Crear la funcion dentro del archivo FUNCTIONS.PHP (si el mismo no existe, lo creamos)
  3.  // Paginador
  4.  function paginate()
  5.  {
  6.      global $wp_query, $post;
  7.      $big = 999999999; // need an unlikely integer
  8.      
  9.      if (is_single())
  10.      {
  11.         echo '<div class="alignleft">';
  12.         previous_post_link('%link', '&laquo; Anterior');
  13.         echo '</div>';
  14.         echo '<div class="alignright">';
  15.         next_post_link('%link', 'Siguiente &raquo;');
  16.         echo '</div><div class="clear"></div>';
  17.      }
  18.      else
  19.      {
  20.          echo paginate_links( array(
  21.             'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
  22.             'format' => '?paged=%#%',
  23.             'current' => max( 1, get_query_var('paged') ),
  24.             'total' => $wp_query->max_num_pages
  25.          ) );
  26.     }
  27.  }
  28.  
  29.  // 2. Ubicar la funcion <?php paginate() ?> donde queramos que aparezca el paginador
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement