Naposledy aktivní 1713290210

Malin's Avatar Malin revidoval tento gist 1713290210. Přejít na revizi

1 file changed, 9 insertions

change-products-per-page.php(vytvořil soubor)

@@ -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 +
Novější Starší