[Resolved] Seperate WooCommerce Categories and Products

Home Forums Support [Resolved] Seperate WooCommerce Categories and Products

Home Forums Support Seperate WooCommerce Categories and Products

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #1714514
    Neil

    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 advance

    #1714777
    Elvin
    Staff
    Customer Support

    Hi 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.

    #1714920
    Neil

    Elvin,
    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 Settings

    #1715069
    David
    Staff
    Customer Support

    Hi there,

    takes custom development to split the categories into a separate list… but this tutorial shows you how to do it:

    https://code.tutsplus.com/tutorials/display-woocommerce-categories-subcategories-and-products-in-separate-lists–cms-25479

    I would suggest testing on a staging site to make sure sub-sub categories are working correctly.

    #1715077
    Neil

    David,

    That seems to be exactly what I was looking for. Perfect.

    Thanks for your help.
    Neil

    #1715148
    David
    Staff
    Customer Support

    You’re welcome

    #2223582
    Annamari
    #2223964
    Leo
    Staff
    Customer Support

    Thanks for sharing!

    #2548833
    sparkle

    oh no! where did it go now?

    #2548866
    Neil
    #2549048
    Leo
    Staff
    Customer Support

    Thanks Neil!

    #2549063
    sparkle

    weird. that link 404s for me too.

    #2549624
    Neil

    That 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.

    #2549945
    David
    Staff
    Customer Support

    Thanks for helping out here, and playing find the post 🙂
    Anyone with a blog thats up for some plagerism lol

    #2550573
    Neil

    @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!

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.