How to add a class to a WooCommerce product within the product loop
How to add a class to a WooCommerce product within the product loop
I would like to add multiple bootstrap col classes to this line of code inside the product loop but I have no idea.
<li><?php wc_product_class(); ?></li>
Can I somehow push my classed into this bit of php and still keep the product applied?
2 Answers
2
try this <li <?php wc_product_class("col-md-4 col-sm-6 custom-class m-4"); ?>></li>
<li <?php wc_product_class("col-md-4 col-sm-6 custom-class m-4"); ?>></li>
For this wc_product_class();
uses two arguments one is class name and other one is product id so just pass your class name as first argument and product id in second one.
wc_product_class();
you could see the wc_product_class() in /woocommerce/includes/wc-template-functions.php
For example your class name is test
and product id is 143
then just pass <li><?php wc_product_class('test',143); ?></li>
test
143
<li><?php wc_product_class('test',143); ?></li>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.