I am using WP-PageNavi plugin, which I incorporated into my custom tpl page. There is woocommerce shortcode which holds all the products that I want to display, but I only ever see the same ones and only one page results. I do not see what am I doing wrong. The code is:

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

    <div class="wrapper clearfix">

            <?php $args = array(
                    'post_type' => 'page',
                    'orderby' => 'title',
                    'order' => 'ASC',
                    'posts_per_page' => 5,
                    'paged' => get_query_var('paged'),

                ); ?>
          <?php query_posts($args); ?>

          <?php if ( have_posts() ) : ?>
              <?php while ( have_posts() ) : the_post(); ?>

              <?php endwhile; ?>
          <?php endif; ?>

            <h2>SHINE kolekcija</h2>    


 echo do_shortcode( '[product_attribute attribute="kolekcije" filter="shine"]' );

 <div class="naviButs">
            <?php wp_pagenavi(); ?>


    <?php  get_footer(); ?>
  • 1
    You want to show pagination of what? Products pagination? or anything else's?
    – Rishabh
    Nov 15, 2016 at 9:34
  • 1
    Yes, products pagination. I managed to show pagination, but it always shows the same result. The code above is what I have now. For example - I click on page 2 or 3 and I still see the results from page 1. Whatever pagination page I want to see, it always shows the same results. (and that is products from page one)
    – Nancy
    Nov 15, 2016 at 9:41

2 Answers 2


In case of wp_query, you can't use shortcode this way

<?php wp_pagenavi(); ?>

You need to use variable (in which you are storing wp_query) in array inside shortcode. Use shortcode like this instead. Replace above shortcode with below one.

<?php wp_pagenavi( array( 'query' => $query_slider ) ); ?>


This is a way in which I am using wp_query to show products list without shortcode that you used to display products.

Template Name: shine
get_header(); ?>
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array('post_type' => 'product',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 5, 
'paged' => $paged);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
 <li style="list-style:none;">
    <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title();?></a>&nbsp;(<?php echo get_the_date('d.m.Y');?>)</h3>
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
/*****     Thumbnail     ******/
    array(120, 90), 

        'class' => 'enter-class-here',   //Specify class for product's image if any
        'alt' => 'Preview unavailable', //Specify alternate text for products, in case if there is no products image
        'title' => 'Enter-title-here'  //Specify title if any
/*******     Thumbnail Ends   ********/
?>      </a>   
</li><hr />
endwhile; ?>

<?php wp_pagenavi( array( 'query' => $loop ) ); ?>
<?php get_footer();?>
  • Thank you for the reply. I am not trying to show custom post slide pagination (which is why I said the woocommerce shortcode is where I am pulling my products from). I am trying to paginate the products that I get from that woocommerce shortcode. I will edit the code to show only relevant lines.
    – Nancy
    Nov 15, 2016 at 8:52
  • @Nancy Check the updated answer
    – Rishabh
    Nov 15, 2016 at 9:54
  • this way the pagination is working, BUT now it shows all products. The shortcode I used was to show only products for which I set custom attribute named "shine". Would you know how to manage that?
    – Nancy
    Nov 15, 2016 at 10:05
  • @Nancy Sorry, No Idea right now! Either search on google to find way to filter products list or wait for better answer by someone else :)
    – Rishabh
    Nov 15, 2016 at 10:11
  • I appreciate you trying to help, anyway!
    – Nancy
    Nov 15, 2016 at 10:15

Using query_posts will always kill any hope of any pagination to be successfully done. You should use the pre_get_posts filter to adjust the main query if you care about pagination.

It will be actually hard to achieve if you need whatever you do in a context of a page template and you should better use your own URL structure by adding appropriate rewrite rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.