WooCommerce 在列表中添加类名 [英] WooCommerce add class name in the list
问题描述
目前,我正在尝试自定义覆盖 WooCommerce.php 文件.现在,在这个文件中,
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>
输出喜欢:
<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>
我想做的是改变类名,目前类名是post-15 product ...
.我想将类名更改为产品类别.
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.
有人可以帮我吗?
推荐答案
请参考 覆盖模板通过首先是一个主题.
woocommerce 模板文件夹中有一个名为 content-product.php 的文件.
There is a file called content-product.php in woocommerce templates folder.
find
find <li <?php post_class( $classes ); ?>> ......... </li>
由 $classes
生成的类.您可以将新课程添加到其中.只需在 标签之前添加以下代码即可.就这个.
<?php $classes[] = '你的新班级' ?>;
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' ?>;
附注.不要直接编辑您的插件模板文件.在您的主题目录中创建名为 woocommerce 的新文件夹,并将 woocommerce 模板文件复制到该文件夹中.然后编辑文件.
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.
这篇关于WooCommerce 在列表中添加类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!