Вы находитесь на странице: 1из 2

<?

php
$counter = 0 ;
$paged = ( get_query_var('paged') ) ? get_query_var('paged') :
1;
$custom_args = array(
'post_type' => 'gallery',
'posts_per_page' => 8,
'paged' => $paged,
);

$custom_query = new WP_Query( $custom_args ); ?>

<?php if ( $custom_query->have_posts() ) : ?>


<?php while ( $custom_query->have_posts() ) :
$custom_query->the_post(); ?>
<?php $counter+=3; ?>
<div class="col-md-3">
<div class="gallery-pic">
<a href="<?php the_permalink() ?>"><?php echo
get_the_post_thumbnail( null, $size, $attr ); ?></a>
</div>
</div>
<?php if ($counter % 12 == 0) { ?>
<div class="clearfix"></div>
<?php } ?>

<?php endwhile; ?>

<!-- end of the loop -->

<!-- pagination here -->


<div class="col-md-12 col-sm-12">
<div class="first-pagination" style="padding-top: 30px">
<span class="page-arrow"><i class="fa fa-angle-
double-right"></i></span>
<?php

$total_pages = $custom_query->max_num_pages;

if ($total_pages > 1){

$current_page = max(1, get_query_var('paged'));

echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('PREVIOUS PAGE '),
'next_text' => __('NEXT PAGE'),
));
}
?>
<span class="page-arrow"><i class="fa fa-angle-double-
left"></i></span>
</div>
</div>

<?php else: ?>


<?php endif; ?>
<?php wp_reset_postdata();?>

Вам также может понравиться