wp_pagenavi does not work in category.php

0

I downloaded and installed the Plugin wp_pagenavi I placed at the end of my code, it appears only that page does not click, either 2 ... 3 ... it does not page, it always repeats items 1 to 10.

Code

<?php get_header(); ?>
    <div class="contentCenter">
        <div class="internalContent">
            <h1> <?php echo "Categoria "; single_cat_title(''); ?> </h1>
            <?php query_posts($query_strings . "&order=ASC"); ?>

            <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
                <div class="postList">
                    <div class="postListImage">
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                            <?php the_post_thumbnail(array(198, 198)); ?>
                        </a>
                    </div>
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <p style="font-size:12px; margin-top:4px;">
                        <i>Publicado por <strong><?php the_author(); ?></strong> em <strong> <?php the_time('d/m/Y'); ?></strong></i>
                    </p>
                    <?php the_excerpt(); ?>
                    <a href="<?php the_permalink(); ?>" id="read_more_link">
                        Continuar Lendo >>
                    </a>
                    <div class="visualClear"></div>
                </div>
            <?php
                endwhile;
                else:
            ?>
                <p class="no-posts-found">Nenhum post encontrado.</p>
            <?php
                endif;
            ?>
        <?php wp_pagenavi(); ?>
        </div>
    </div>
<?php get_footer(); ?>

What could I do to make it work?

Note: I'm new to Wordpress.

    
asked by anonymous 16.11.2016 / 19:51

2 answers

0

See if this sets the limit you want on line 5:

<?php
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 $args = array('posts_per_page' => '8'); 
 query_posts($args . $query_strings . '&order=ASC&paged=' . $paged);
?>
    
16.11.2016 / 20:07
0

wp_pagenavi is failing because your query is being overwritten with query_posts() . The internet will tell you otherwise, but it is never a good idea to use query_posts () because this function messes up all the global variables in the theme and causes these types of problems.

The plugin is implemented correctly but instead of calling query_posts on line 5 the changes to the query should be made to your functions.php file using the pre_get_posts .

Example:

add_action('pre_get_posts', 'modifica_query_category');
function modifica_query_category( $query ) {
    // modifica apenas a query principal de arquivos de categoria
    if ( $query->is_main_query() && is_category() ) {
        // altera a ordem para ascendente
        $query->set('order', 'ASC');
    } 
}

This eliminates duplicate queries, improves site performance, and corrects paging errors at once:

    
16.11.2016 / 20:59