Skip to content

Instantly share code, notes, and snippets.

@AnkanSoul
Created April 25, 2018 15:43
Show Gist options
  • Select an option

  • Save AnkanSoul/3ba3e005cbabfbabfb44fdb1f8c78b3f to your computer and use it in GitHub Desktop.

Select an option

Save AnkanSoul/3ba3e005cbabfbabfb44fdb1f8c78b3f to your computer and use it in GitHub Desktop.
Pagination
<?php
if (get_query_var('paged')) {
$paged = get_query_var('paged');
}
elseif (get_query_var('page')) {
$paged = get_query_var('page');
} else {
$paged = 1;
}?>
<?php
$args=array(
'post_type' => 'post',
'fields' => 'ids',
'order' => 'ASC',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null,
'posts_per_page' => 2,
'paged' => $paged
) ;
$the_qyery= new WP_Query($args);
if ($the_qyery->have_posts()) :
while ( $the_qyery->have_posts() ) : $the_qyery->the_post();?>
<article class="post clearfix pt-30 pb-30">
<div class="row">
<div class="col-sm-5">
<div class="entry-header">
<div class="post-thumb"> <img class="img-responsive img-fullwidth" src="<?php echo the_post_thumbnail_url(); ?>" alt=""> </div>
</div>
</div>
<div class="col-sm-7">
<div class="entry-content mt-0">
<a href="<?php the_permalink(); ?>"><h4 class="entry-title mt-0 pt-0"><?php the_title(); ?></h4></a>
<ul class="list-inline font-12">
<li>Posted by <a href="#" class="text-theme-colored"><?php the_author(); ?> |</a></li>
<li><span class="text-theme-colored"><?php echo get_the_time('D'); ?> <?php echo get_the_time('M'); ?> <?php echo get_the_time('Y'); ?></span></li>
</ul>
<p class=""><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>"></a></p>
<ul class="list-inline like-comment pull-left font-12">
<li><i class="pe-7s-comment"></i>36</li>
<li><i class="pe-7s-like2"></i>125</li>
</ul>
<a class="pull-right text-gray font-13" href="<?php the_permalink(); ?>"><i class="fa fa-angle-double-right text-theme-colored"></i> Read more</a>
<?php echo do_shortcode("[addtoany]"); ?>
</div>
</div>
</div>
</article>
<?php endwhile;
if ($the_qyery->max_num_pages > 1) :
$orig_query = $wp_query;
$wp_query = $the_qyery;
?>
<nav class="prev-next-posts">
<?php
if (function_exists('wp_bootstrap_pagination'))
wp_bootstrap_pagination();
?>
</nav>
<?php $wp_query = $orig_query; ?>
<?php endif;
wp_reset_postdata();
else:
echo '<p>' . __('Sorry, no posts matched your criteria.') . '</p>'; //ends pagination
endif; //ends loop
?>
</div>
</div>
<div class="col-md-3">
<div class="sidebar sidebar-right mt-sm-30">
<?php get_sidebar(); ?>
</div>
</div>
</div>
</div>
</div>
</section>
<!--End Blog-->
<!-- end main-content -->
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment