Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
WooCommerce product page pagination showing duplicates in all pages

I am getting the same results for each page using the WooCommerce pagination. What am I doing wrong? Maybe it lacks postdata reset somewhere? This is my code example:

Link to full code—>

$products = new WP_Query($product_args);
if ($products->have_posts()):
    while ($products->have_posts()):
        $products->the_post();
        wc_get_template_part("content", "product");
    endwhile;
    wp_reset_postdata($products);
endif;
 
echo paginate_links([
    "base" => str_replace(
        999999999,
        "%#%",
        esc_url(get_pagenum_link(999999999))
    ),
    "total" => $products->max_num_pages,
    "current" => max(1, get_query_var("paged")),
    "format" => "?paged=%#%",
    "show_all" => false,
    "type" => "list",
    "end_size" => 2,
    "mid_size" => 4,
    "prev_next" => true,
    "prev_text" => is_rtl() ? "→" : "←",
    "next_text" => is_rtl() ? "←" : "→",
    "add_args" => false,
    "add_fragment" => "",
]);
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Thanks to @Outsource WordPress comment I was lead to a solution. I changed the part of my code like this and got it working. I replaced offset with paged:

$product_args = [
"post_type" => "product",
"post_status" => "publish",
"orderby" => "ID",
"suppress_filters" => false,
"order" => "ASC",
"paged" => max(1, get_query_var('paged')),
"posts_per_page" => "16",
];
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda