C
C
chelnokov_a2020-05-18 17:22:02
WooCommerce
chelnokov_a, 2020-05-18 17:22:02

How to limit the number of products per category page in woocommerce?

Good afternoon. I already asked the question in the title. It is necessary that when you open the store page or any category, a maximum of 9 products are displayed. Accordingly, to see more - pagination. I cannot resolve this issue.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WP Panda, 2020-05-18
@wppanda5 WooCommerce

function my_posts_per_page( $query ) {
  if ( is_admin() || ! $query->is_main_query() ) {
    return;
  }

  if ( is_shop() || is_product_category() || is_product_tag() ) {
    $query->set( 'posts_per_page', 9 );
  }

}

add_action( 'pre_get_posts', 'my_posts_per_page' );

P
Pychev Anatoly, 2020-05-18
@pton

/**
 * Изменяем количество товаров на странице.
 */
function pan_loop_shop_per_page() {
  return 50;
}
add_filter( 'loop_shop_per_page', 'pan_loop_shop_per_page', 20 );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question