Advertisement
Guest User

Random code 233

a guest
Apr 4th, 2022
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2. $prod_categories = [
  3.     "204",
  4.     "232",
  5.     "228",
  6.     "231",
  7.     "191",
  8.     "230",
  9.     "229",
  10.     "201",
  11.     "244",
  12. ];
  13. $product_args = [
  14.     "post_type" => "product",
  15.     "post_status" => "publish",
  16.     "orderby" => "ID",
  17.     "suppress_filters" => false,
  18.     "order" => "ASC",
  19.     "offset" => 0,
  20.     "posts_per_page" => "16",
  21. ];
  22.  
  23. if (!empty($prod_categories)) {
  24.     $product_args["tax_query"] = [
  25.         [
  26.             "taxonomy" => "product_cat",
  27.             "field" => "id",
  28.             "terms" => $prod_categories,
  29.             "operator" => "IN",
  30.         ],
  31.     ];
  32. }
  33. $products = new WP_Query($product_args);
  34. if ($products->have_posts()):
  35.     while ($products->have_posts()):
  36.         $products->the_post();
  37.         wc_get_template_part("content", "product");
  38.     endwhile;
  39.     wp_reset_postdata($products);
  40. endif;
  41.  
  42. echo paginate_links([
  43.     "base" => str_replace(
  44.         999999999,
  45.         "%#%",
  46.         esc_url(get_pagenum_link(999999999))
  47.     ),
  48.     "total" => $products->max_num_pages,
  49.     "current" => max(1, get_query_var("paged")),
  50.     "format" => "?paged=%#%",
  51.     "show_all" => false,
  52.     "type" => "list",
  53.     "end_size" => 2,
  54.     "mid_size" => 4,
  55.     "prev_next" => true,
  56.     "prev_text" => is_rtl() ? "&rarr;" : "&larr;",
  57.     "next_text" => is_rtl() ? "&larr;" : "&rarr;",
  58.     "add_args" => false,
  59.     "add_fragment" => "",
  60. ]);
  61. ?>
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement