Created
June 8, 2015 15:17
-
-
Save jandrodev/5b9a42f9e79446051883 to your computer and use it in GitHub Desktop.
Función paginador y aplicación en archivo de plantilla.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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