2014-02-13 50 views
2

當前,我試圖自定義重寫WooCommerce.php文件。現在,在這個文件中,WooCommerce在列表中添加類名稱

<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 ...。我想將類名更改爲產品類別。

有人能幫助我嗎?

回答

10

請先參考overriding templates via a theme

woocommerce模板文件夾中有一個名爲content-product.php的文件。

發現<li <?php post_class($classes); ?>> ......... </li>的類已通過$classes產生

。你可以添加你的新課程。只需在<li>標籤之前添加以下代碼即可。就這個。 <?php $classes[] = 'your-new-class' ?>;

PS。不要直接編輯你的插件模板文件。在您的主題目錄中創建名爲woocommerce的新文件夾,並將woocommerce模板文件複製到該文件夾​​。然後編輯文件。

+1

我認爲他應該標記正確的答案無論如何有幫助。 –

相關問題