WooCommerce add class name in the list

2019-07-20 22:09发布

Currently, I am trying to customise the override WooCommerce.php file. Now, in this file,

<section id="content woocommerce" class="grid-block woocommerce">
<ul id="products" class="subcategory-products products">
<?php woocommerce_content(); ?>
</ul>
</section>

The output likes:

<li class="post-15 product type-product status-publish hentry first instock">
    <a href="http://shop.bbpixelz.dk/product/i-phone-ai-template/">
        <img width="150" height="150" src="http://shop.bbpixelz.dk/wp-content/uploads/2014/01/iphone-ai-template-150x150.png" class="attachment-shop_catalog wp-post-image" alt="iphone-ai-template">
        <h3>I-Phone Vector Template</h3>
    <span class="price"><span class="amount">$2</span></span>
    </a>
    <a href="/?add-to-cart=15" rel="nofollow" data-product_id="15" data-product_sku="ai-iphone" class="add_to_cart_button button product_type_simple">Add to cart</a>
</li>

What I am trying to do is to change the class name, currently the class name is post-15 product .... I would like to change the class name to product category.

Could someone help me?

1条回答
一夜七次
2楼-- · 2019-07-20 22:32

Please refer overriding templates via a theme first.

There is a file called content-product.php in woocommerce templates folder.

find <li <?php post_class( $classes ); ?>> ......... </li>

that classes you have generated by $classes . you can add your new class to it. just add following code to right before the <li> tag. here is it. <?php $classes[] = 'your-new-class' ?>;

PS. dont edit your plugin template files directly. Create new folder called woocommerce in your theme directory and copy woocommerce template files to that folder. and then edit files.

查看更多
登录 后发表回答