Last active
December 14, 2015 13:43
-
-
Save diegoliv/2e2ce0048c29baec3619 to your computer and use it in GitHub Desktop.
Custom loop pagination in single post type template
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
<?php get_header(); ?> | |
<div class="container"> | |
<div class="row"> | |
<?php | |
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; | |
$disciplinas = new WP_Query( array( | |
'post_type' => 'disciplinas', | |
'posts_per_page' => 3, | |
'paged' => $paged | |
) ); | |
?> | |
<?php if( $disciplinas->have_posts() ) : ?> | |
<?php while ( $disciplinas->have_posts() ) : $disciplinas->the_post(); ?> | |
<div class="col-md-4"> | |
<div class="panel panel-default"> | |
<div class="panel-body"> | |
<h3><?php the_title() ?></h3> | |
<a href="<?php the_permalink() ?>" class="btn btn-primary"><?php _e( 'Ver Disciplina' ) ?></a> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
<?php previous_post_link( __( 'Prev' ), $disciplinas->max_num_pages ); ?> | |
<?php next_post_link( __( 'Next' ), $disciplinas->max_num_pages ); ?> | |
<?php wp_reset_postdata(); ?> | |
</div> | |
</div> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment