1 回答

TA貢獻1883條經驗 獲得超3個贊
請記住將 woocommerce/template/loop/loop-start.php 和 loop-end.php 復制到你的 theme/woocommerce/loop/loop-start.php 和 loop-end.php
循環/loop-start.php
/*This is the main cat on homepage or shop page*/
if (is_shop()|| is_front_page()) {
/*this can be any thing you want it to be <ul><div>*/
echo '<div class="yourclass">';
}?
/*this should be your sub categories 1 level down*/
else if ( is_product_category(array('cat1', 'cat2','cat3', 'cat4', 'cat5'))){
/*this can be any thing you want it to be <ul><div>*/
echo '<div class="yourclass">';
}
/*this should be your sub categories 2 level down*/
?else if ( is_product_category(array('subcat1','subcat2'))){
echo '<ul class="products" id="NORMAL">';
}
然后在loop-end.php
/*This is the main cat on homepage or shop page*/
? ? if (is_shop()|| is_front_page()) {
? ? /*this can be any thing you want it to be <ul><div>*/
? ? echo '</div>';
? ? }?
? ? /*this should be your sub categories 1 level down*/
? ? else if ( is_product_category(array('cat1', 'cat2','cat3', 'cat4', 'cat5'))){
? ? /*this can be any thing you want it to be <ul><div>*/
? ? echo '</div>';
? ? }
? ? /*this should be your sub categories 2 level down*/
? ? ?else if ( is_product_category(array('subcat1','subcat2'))){
? ? echo '</ul>';
? ? }
應該有更好的方法來做到這一點,但對我來說,這是我所能做的。
- 1 回答
- 0 關注
- 157 瀏覽
添加回答
舉報