Answer the question
In order to leave comments, you need to log in
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
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' );
/**
* Изменяем количество товаров на странице.
*/
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 questionAsk a Question
731 491 924 answers to any question