Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $prod_categories = [
- "204",
- "232",
- "228",
- "231",
- "191",
- "230",
- "229",
- "201",
- "244",
- ];
- $product_args = [
- "post_type" => "product",
- "post_status" => "publish",
- "orderby" => "ID",
- "suppress_filters" => false,
- "order" => "ASC",
- "offset" => 0,
- "posts_per_page" => "16",
- ];
- if (!empty($prod_categories)) {
- $product_args["tax_query"] = [
- [
- "taxonomy" => "product_cat",
- "field" => "id",
- "terms" => $prod_categories,
- "operator" => "IN",
- ],
- ];
- }
- $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" => "",
- ]);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement