- This topic has 20 replies, 6 voices, and was last updated 1 year, 1 month ago by David.
-
AuthorPosts
-
March 29, 2021 at 11:17 am #1714514Neil
Within Reading Settings I have “Blog pages show at most” set to 24, and in the Customiser “Layout => Woocommerce” set to show products in 4 columns, which together gives a nice 4×6 grid on desktop.
Additionally, within the Customiser I have the setting “Woocommerce => Product Catalogue” set “Category display” to “Show subcategories & products” which is great in that is give the website visitor a chance to “refine or buy”.
However when the subcategories are an odd number this throws the product grid off.
Is there a way to have some kind of break after the categories so that the products will always be a 4×6 grid?
I have looked at the css classes, but can only see that the categories are individually targetable, rather than seperating the categories from the products.
Many thanks in advanceMarch 29, 2021 at 7:53 pm #1714777ElvinStaffCustomer SupportHi there,
We should be able to change the number of post per page displayed for ALL the product archive pages.
Try this PHP snippet.
function hwl_home_pagesize( $query ) { if ( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'product' ) ) { // Display # posts for a custom post type called 'product' (WooCommerce) $query->set( 'posts_per_page', 24 ); return; } } add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );
I’ve added
24
because 4 x 6 = 24. This is so the post displayed doesn’t exceed 24 posts so there’s no 7th row w/ oddly placed products.March 30, 2021 at 12:11 am #1714920NeilElvin,
Thanks for the update, which I have tried, but unfortunately this seems to be the same result as setting the “Blog pages show at most” from Settings => Reading SettingsMarch 30, 2021 at 3:54 am #1715069DavidStaffCustomer SupportHi there,
takes custom development to split the categories into a separate list… but this tutorial shows you how to do it:
I would suggest testing on a staging site to make sure sub-sub categories are working correctly.
March 30, 2021 at 4:00 am #1715077NeilDavid,
That seems to be exactly what I was looking for. Perfect.
Thanks for your help.
NeilMarch 30, 2021 at 5:36 am #1715148DavidStaffCustomer SupportYou’re welcome
May 18, 2022 at 6:22 am #2223582AnnamariThe URL of the tutorial above has changed, this is the correct one: https://code.tutsplus.com/tutorials/display-woocommerce-categories-subcategories-and-products-in-separate-lists–cms-25479
May 18, 2022 at 9:47 am #2223964LeoStaffCustomer SupportThanks for sharing!
February 27, 2023 at 8:45 am #2548833sparkleoh no! where did it go now?
February 27, 2023 at 9:01 am #2548866NeilWhy, oh why, do they keep moving it?!
February 27, 2023 at 11:04 am #2549048LeoStaffCustomer SupportThanks Neil!
February 27, 2023 at 11:16 am #2549063sparkleweird. that link 404s for me too.
February 28, 2023 at 2:21 am #2549624NeilThat is really weird. I checked before posting yesterday and everything was working, but also now giving a 404 for me as well.
The one way that I can find it is searching for the article ID: https://code.tutsplus.com/tutorials/search/25479
Hope that helps.
February 28, 2023 at 7:20 am #2549945DavidStaffCustomer SupportThanks for helping out here, and playing find the post 🙂
Anyone with a blog thats up for some plagerism lolFebruary 28, 2023 at 2:26 pm #2550573Neil@david You got me on a train of thought, and then I went a step further to just put it all together in a plugin!
https://github.com/EncodeDotHost/edh-woo-categories
Now to submit to the WP Repository for the first time!
-
AuthorPosts
- You must be logged in to reply to this topic.