Skip to content

Instantly share code, notes, and snippets.

@jandrodev
Created June 8, 2015 15:17
Show Gist options
  • Save jandrodev/5b9a42f9e79446051883 to your computer and use it in GitHub Desktop.
Save jandrodev/5b9a42f9e79446051883 to your computer and use it in GitHub Desktop.
Función paginador y aplicación en archivo de plantilla.
function paginador() {
global $wp_query;
$int = 999999999;
echo paginate_links( array(
'base' => str_replace( $int, '%#%', esc_url( get_pagenum_link( $int ) ) ),
'format' => '?paged=%#%',
'prev_text' => __(' Anterior '),
'next_text' => __(' Siguiente '),
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages )
);
}
// Colocar esto en archivo de plantilla !
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'paged' => $paged
)
);
if(have_posts()) : while(have_posts()) : the_post();
[...]
endwhile; ?>
<div class="paginador">
<?php paginador(); ?>
</div>
<?php else : ?>
<p>Lo siento, no hay entradas para ti</p>
<?php endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment