Erroneous paging count in wordpress

Asked

Viewed 70 times

0

When the Slug stored in var $type is for example 'pizzas-salgadas' the pagination rolls normally, now when this Slug changes, the pagination appears even without the need to appear, with several blank pages. It’s like I’m counting all the results for all the Slug’s.

Query and Loop

    $argsProdutos = array ( 
        'post_type'     => 'cardapios',
        'post_status'   => 'published',
        'orderby'       => 'name',
        'order'         => 'ASC',
        'tax_query'     => array(
                        array(
                        'taxonomy' => $taxonomy,
                        'field' => 'slug',
                        'terms' => $tipo
                        )
        ),
        'paged' => $paged 
    );

    $produto = new WP_Query( $argsProdutos );

    // THE LOOP
    if ( $produto->have_posts() ) : while ( $produto->have_posts() ) : $produto->the_post(); 

?>

    <!-- EXAMPLE -->
    <h1><?php the_title();?></h1>

<?php

    endwhile; wp_reset_query();

    endif;

    pagination_links();

?>

Paging

function pagination_links() {

        global $wp_query;
        $total = $wp_query->max_num_pages;

        if ( $total > 1 )  {

            if ( !$current_page = get_query_var('paged') )
                $current_page = 1;

                $big = 999999999;

                $permalink_structure = get_option( 'permalink_structure' );
                $format = empty( $permalink_structure ) ? '&page=%#%' : 'page/%#%/';

                echo '<div class="pagination">';
                    echo paginate_links( array(
                        'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
                        'format' => $format,
                        'current' => $current_page,
                        'total' => $total,
                        'mid_size' => 4,
                        'type' => 'plain'
                    ));
                echo '</div>';
            }

    }

  • Is it possible to illustrate with images? It was not clear to me only with the description. Sorry.

  • @Fellipesoares opaa, cara aqui é um cardapio que tem itens suficiente para paginar http://imgur.com/Kmr2weQ, aqui é um menu que tem apenas 6 itens e mesmo assim aparece a paginação http://imgur.com/I9JHE6g, mas quando clico na página 2 http://imgur.com/pAckPaz mostra nada, because really have no items there paginar.

  • It is necessary to research the correct solution, but call global $wp_query after a new WP_Query() and a wp_reset_query() seems to be the root of the problem. . . . PS: please prefer [Edit] the question to add details (explanations and snapshots).

  • SOLVED WITH THE SOLUTION BELOW http://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.