Created
December 10, 2018 18:38
-
-
Save eliasfaical/d331b19442e62d2d334a6d2e84953817 to your computer and use it in GitHub Desktop.
Paginação WP
This file contains 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
<?php | |
$category = get_the_category(); | |
$args_post = array( | |
'post_type' => 'post', | |
'posts_per_page' => 16, | |
'paged' => get_query_var('paged') ? get_query_var('paged') : 1 | |
); | |
$query_post = new WP_Query( $args_post ); | |
if ( $query_post->have_posts() ) : | |
while ( $query_post->have_posts() ) : $query_post->the_post(); | |
?> | |
<div class="item-article"> | |
<div class="row"> | |
<div class="col-md-3"> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="link-thumb"> | |
<img class="img-fluid card-img-top" src="<?php the_post_thumbnail_url(); ?>" alt=""> | |
</a> | |
</div> | |
<div class="col-md-9"> | |
<span class="date-post"> | |
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> <?php the_time('d/m/Y'); ?> | |
</span> | |
<?php | |
foreach((get_the_category()) as $category) { | |
$term_link = get_term_link( $category ); | |
echo '<a class="category-post" href="'. esc_url( $term_link ) .'">'. $category->cat_name .'</a>'; | |
} | |
?> | |
<h4> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="link-thumb"> | |
<?php the_title(); ?> | |
</a> | |
</h4> | |
<?php | |
$the_excerpt = get_the_excerpt(); | |
echo string_limit_words( $the_excerpt, 20 ) . ' [...]'; | |
?> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="btn-default">Leia mais</a> | |
</div> | |
</div> | |
</div> | |
<?php | |
endwhile; | |
endif; | |
echo '<div class="pagination">'; | |
$big = 999999999; // need an unlikely integer | |
echo paginate_links( array( | |
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, get_query_var('paged') ), | |
'total' => $query_post->max_num_pages | |
) ); | |
echo '</div>'; | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment