Dernière activité 1713290210

Malin's Avatar Malin a révisé ce gist 1713290210. Aller à la révision

1 file changed, 9 insertions

change-products-per-page.php(fichier créé)

@@ -0,0 +1,9 @@
1 + add_action( 'pre_get_posts', 'custom_woocommerce_products_per_page' );
2 +
3 + function custom_woocommerce_products_per_page( $query ) {
4 + // Check if we're on a WooCommerce shop page or product category or tag page and if it's the main query
5 + if( !is_admin() && $query->is_main_query() && (is_woocommerce() || is_product_category() || is_product_tag()) ) {
6 + $query->set( 'posts_per_page', 9 ); // Set the number of products per page to 12
7 + }
8 + }
9 +
Plus récent Plus ancien