Site logo

[Resolved] How to center products on shop page (WooCommerce)

Home Forums Support [Resolved] How to center products on shop page (WooCommerce)

Home Forums Support How to center products on shop page (WooCommerce)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1811687
    Marc-Andre

    Hi, I simply want to center the products and categories on the shop page. The shop page on desktop is 4 elements per row, but when there is less than 4, I would like them to center themselves. Is it possible? I tried many CSS available online without success.

    #1811741
    Leo
    Staff
    Customer Support

    Hi there,

    Unfortunately I don’t think that’s possible as the grid is set for 4 products per row.

    You would need to use this filter to set it to 3 or less when there isn’t enough products to fill the row:
    https://docs.generatepress.com/article/option_generate_woocommerce_settings/#options-%E2%80%98columns%E2%80%99

    #1811753
    Marc-Andre

    Thank you for the information. I looked at the provided resource and I understand that I can use PHP to accomplish this. I added the code snippet plugin after reading other GP articles. I understand that I can use the provided example at the bottom of the page and that I need to write a conditional ”if” that says if there is 3 elements or less, use 3 columns, but I don’t know how to write it correctly.

    #1811794
    Leo
    Staff
    Customer Support

    If you are referring to the main shop page, then you can actually use the customizer option.

    There isn’t a way to identify how many products there are in the loop without some custom coding which is outside the scope of this forum unfortunately as that’s handled within the WooCommerce plugin itself.

    You will basically need to set it to 3 when you only have 3 products, then set it to 4 when you have more products.

    #1811801
    Marc-Andre

    Good to know. Thank you for support!

    #1811804
    Leo
    Staff
    Customer Support

    No problem 🙂

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