第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Woocommerce 產(chǎn)品/類別循環(huán)問(wèn)題

Woocommerce 產(chǎn)品/類別循環(huán)問(wèn)題

PHP
翻閱古今 2023-04-21 17:23:25
我安裝了最新的 Woocommerce 和最新的 Wordpress。我已經(jīng)安裝了網(wǎng)格/列表切換。我的問(wèn)題從這里開始。因?yàn)樗鼘⑺蓄悇e和產(chǎn)品更改為列表視圖我想要網(wǎng)格視圖中的類別和列表視圖中的產(chǎn)品。所以我搜索并發(fā)現(xiàn)類別和產(chǎn)品在 template/loop/loop-start.php 上使用相同的開始和結(jié)束循環(huán)“>可以在那里更改它,但隨后它會(huì)將所有內(nèi)容更改為該類。現(xiàn)在我的解決方案是向此頁(yè)面添加條件標(biāo)簽但這有點(diǎn)問(wèn)題。見代碼<?php/** * Product Loop Start * * This template can be overridden by copying it to yourtheme/woocommerce/loop/loop-start.php. * * HOWEVER, on occasion WooCommerce will need to update template files and you * (the theme developer) will need to copy the new files to your theme to * maintain compatibility. We try to do this as little as possible, but it does * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * * @see         https://docs.woocommerce.com/document/template-structure/ * @package     WooCommerce/Templates * @version     3.3.0 */if ( ! defined( 'ABSPATH' ) ) {    exit;}?><?php if ( is_product_category() ) {  if ( is_shop() ) {    echo '<ul class="product-category1">';  } elseif ( is_product_category( array( 'cd', 'album' ) )) {    echo '<ul class="product-category2">';  } else {    echo '<ul class="products columns-' .esc_attr( wc_get_loop_prop( 'columns' ) );.' ">';  }} ?><!--<ul class="products columns-<?php //echo esc_attr( wc_get_loop_prop( 'columns' ) ); ?>" id="HELP">-->現(xiàn)在上面的代碼有點(diǎn)像 if_shop 語(yǔ)句不起作用,但是 is_product_category 工作得很好,else 語(yǔ)句也不起作用有人可以為此指出正確的方向嗎,幾周來(lái)一直在尋找答案,但由于 Woocommerce 更改了很多代碼,所以沒(méi)有任何答案或太舊而無(wú)法使用。
查看完整描述

1 回答

?
白板的微信

TA貢獻(xiàn)1883條經(jīng)驗(yàn) 獲得超3個(gè)贊

請(qǐng)記住將 woocommerce/template/loop/loop-start.php 和 loop-end.php 復(fù)制到你的 theme/woocommerce/loop/loop-start.php 和 loop-end.php


循環(huán)/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>';

? ? }

應(yīng)該有更好的方法來(lái)做到這一點(diǎn),但對(duì)我來(lái)說(shuō),這是我所能做的。


查看完整回答
反對(duì) 回復(fù) 2023-04-21
  • 1 回答
  • 0 關(guān)注
  • 154 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)