WP-PageNavi is showing the first page only

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:

  ?php 
    /* 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; ?





            h2SHINE kolekcija/h2    


    ?php

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

 div class="naviButs"
            ?php wp_pagenavi(); ?
        /div



            /div




    ?php  get_footer(); ?

Topic plugin-wp-pagenavi php pagination Wordpress

Category Web


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.


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 ) ); ?>

UPDATE

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

<?php
/*
Template Name: shine
*/
get_header(); ?>
<?php 
$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(); ?>">
    <?php 
/*****     Thumbnail     ******/
the_post_thumbnail(
    array(120, 90), 
    array(

        '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 />
<?php 
endwhile; ?>

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

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.