- This topic has 3 replies, 2 voices, and was last updated 4 years, 9 months ago by
Leo.
-
AuthorPosts
-
December 11, 2020 at 11:05 am #1576539
johnaps
Hello!
I have found the bellow two codes but i cant get them to work…
I want to change the number of displayed products in specifically 5 product categories (change the number from 12 to 30)
Only on those 5 though and not in any other!add_filter( 'option_generate_woocommerce_settings', 'tu_custom_wc_columns' ); function tu_custom_wc_columns( $options ) { if ( ! is_product_category( 'audio' ) ) { $options['columns'] = 2; } return $options; }
From Tom (past thread)
/** * Change number of products that are displayed per page (shop page) */ add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 ); function new_loop_shop_per_page( $products ) { // Return the number of products you wanna show per page. $products = 100; return $products; }
From wordpress.stack-exchange
I made those 2 like this
add_filter( 'option_generate_woocommerce_settings', 'tu_custom_wc_columns' ); function tu_custom_wc_columns( $products ) { if ( ! is_product_category( 'νοσοκομειακα-κρεβατια' ) ) { $products = 30; } return $products; }
And i did some other combinations with no luck… This one breaks the styling, and the other one i tried changed it globally to 30 and not just to the one i tested it…
Do you have any insights on this?
Thank you for your time!December 11, 2020 at 7:08 pm #1576873Leo
StaffCustomer SupportHi there,
That is handled by WooCommerce itself so GP’s filter wouldn’t work.
The GP’s filter you’ve shown above only changes the number of columns and not number of products.
I believe this is what you are after:
https://docs.woocommerce.com/document/change-number-of-products-displayed-per-page/You would just need to add the appropriate conditional tags.
If that doesn’t help, any chance you can check with WooCommerce support team first?
Thanks!
December 12, 2020 at 12:29 am #1577077johnaps
I also tried them, but they werent much of help because i am not a premium user…
If Tom or someone can tell me if this is even possible i would very much appreciate it!Thank you for your time, though!
December 12, 2020 at 11:14 am #1577739Leo
StaffCustomer SupportTo change the number of products in certain product categories?
If so it should be possible with the filter I linked above and the conditional tags:
https://docs.woocommerce.com/document/conditional-tags/#section-5 -
AuthorPosts
- You must be logged in to reply to this topic.