Good afternoon
On the category screen when I enter the pool table category it lists me all the products of this category, the big problem is my pagination when I click next page it gets lost and gives me 404 error. Here is the complete code:
$category = get_the_terms( $post->ID, 'product_cat' ); $id_category = $terms[0]->term_id; $name = $terms[0]->name; $slug = $terms[0]->slug; $args = array( 'post_type' => 'product', 'product_cat' => $name, 'post_status' => 'publish', 'posts_per_page' => 2, 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => get_query_var( 'product_cat' ) )), 'orderby' => 'rand' ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); global $product; Aqui faço minha lógica para imprimir o produto somente endwhile; } else { ?> Nenhum produto cadastrado } echo paginate_links( array( 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), total' => $loop->max_num_pages, 'prev_next' => true, 'prev_text' => 'Página Anterior', 'next_text' => 'Próxima Página', 'before_page_number' => '-', 'after_page_number' => '>', 'show_all' => false, 'mid_size' => 3, 'end_size' => 1 )); wp_reset_postdata();