Powered By Blogger

Tuesday, October 11, 2016

pagination in wordpress custom post type category / tags / archive page in wordpress

<?php
/*
Template Name: archive
*/
get_header();
?>

 <!-- <link rel="stylesheet" href="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/css/jPages.css">
  <script type="text/javascript" src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/js/jquery-1.8.2d.min.js"></script>
  <script src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/js/jPages.js"></script>
  <script>
  $(function() {
    $("div.holder").jPages({
      containerID: "itemContainer",
      previous : "←",
      next : "→",
      perPage:5,
      midRange: 5,
      direction: "random"
    });
  });
  </script>-->


<div class="page-heading">
<div class="container">
<div class="col-xs-12">
<h1>Blog</h1>
</div>
</div>
</div>

<div class="container" style="margin-top:30px;">
<div class="col-md-12" id="bread_post"> <?php if(function_exists('bcn_display')){bcn_display();}?>  </div>
<div class="col-md-8 blownew">

 
      <div class="holder"></div>

      <!-- item container -->
    <ul id="itemContainer">

    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <div  id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <!--.post-header-->  
                <div class="entry clear">
<?php
$post_image_id = get_post_thumbnail_id($post_to_use->ID);
if ($post_image_id) {
$thumbnail = wp_get_attachment_image_src( $post_image_id, 'post-thumbnail', false);
if ($thumbnail) (string)$thumbnail = $thumbnail[0];
}
?><li>
<div class="main_blog"><a href="<?php the_permalink(); ?>">
<div style="background:url('<?php echo $thumbnail; ?>') center no-repeat; background-size:100%; height:382px;"></div>
<!-- TITLE -->
<div class="col-md-12 col-sm-12 head_title"><h1><?php the_title(); ?></h1></div>
<div class="col-md-12 col-sm-12 head_title">
<div class="post_view"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/post-view.png"><?php echo do_shortcode('[post-views id=get_the_ID()]'); ?> </div>
<div class="post_date"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/calender.png"><?php the_time( get_option( 'date_format' ) ); ?></div>
<div class="post_author"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/author.png"><?php the_author() ?></div>
<a href="<?php the_permalink(); ?>"><div class="post_comment"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/comments.png"><?php $commentcount = comments_number('0', '1', '%'); $fulltitle = $commentcount . ' comments';
echo $fulltitle; ?></div> </a>
<div class="post_categorynew"><img class="img_cate" src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/category.png"><?php echo the_category(); ?></div>
</div>
<div class="col-md-12 col-sm-12 new_tag" style="margin-bottom: 16px;"><?php the_tags( '<b>Tags:</b> | ', ' | ', '<br />' ); ?>
</div>
<div class="cont_blog"> <?php $content = get_the_content(); echo mb_strimwidth($content, 0, 350, '...');?>  </div>
<div class="readmore_blog"><a href="<?php the_permalink(); ?>"> Read More </a> </div>
</a>
                    <?php wp_link_pages(); ?>
                </div><!--. entry--> </a>
            </div><!-- .post-->

</a></div>
</li>


        <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>

<!-- Add the pagination functions here. -->
<?php
echo "<div class='blog-nav'>";
// Custom query loop pagination
previous_posts_link( '  <<  ' );

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
 'format' => '?paged=%#%',
 'current' => max( 1, get_query_var('paged') ),
 'total' =>  $wp_query->max_num_pages
) );
next_posts_link( '  >>  ', $custom_query->max_num_pages );
echo "</div>";
                 ?>

</ul>
      <div class="holder"></div>
    <?php  else : ?>
    <?php endif; ?>



</div>
<div class="col-md-4 rightsiderbar_blog"> <?php dynamic_sidebar("right-sidebar"); ?> </div>

</div><!--.content-->
<?php get_footer(); ?>


1 comment:

  1. If you're interestd in creating and promoting your webstore,I would be glad to recommend you AmazingCart. Perfect solution for your Online Store. Very efficient app. Easy to install.
    Supports WordPress (WooCommerce), Magento, Opencart and PrestaShop. This is amazing value for money.
    http://amazingcart.us/

    ReplyDelete