0

I tried different codes to be able to use the PageNavi Plugin in category.php, but all were not working. I don't know what was the problem? here is my working category.php code:

   <?php
     $cat = get_the_category();  
     $cat = $cat[0];            
     $catname = get_cat_name($cat->term_id);    
     $catid = get_cat_ID($catname);       
   ?>
                  
   <?php
     $paged = get_query_var('paged', 1);
     $args = array(       
       'paged' => $paged,
       'post_type' => 'post',
       'cat' => $catid,
     );
   $query = new WP_Query($args);  
        global $query_string;
        query_posts( $query_string . "&posts_per_page=1&paged=".$paged );
        while ( have_posts() ) : the_post()
   ?>

I tried and displayed 1 post per page only, so I can see if its working. the 1 post was displayed successfully, however the PageNavi Plugin was not working.

Can anyone help me with this issue?

1 Answer 1

0

I had the same problem but you just have to put the native loop in category.php which is this:

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

then put the function of the plugin:

<?php endwhile; wp_pagenavi(); endif; ?>

Also check in reading settings, how many posts you want to show.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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