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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

產(chǎn)品標(biāo)題旁邊的價格 [woocommerce]

產(chǎn)品標(biāo)題旁邊的價格 [woocommerce]

PHP
慕蓋茨4494581 2023-04-15 16:50:06
我有這個功能,我想在產(chǎn)品價格旁邊添加。我用過get_price_html()和$price = $product->get_price_htmlfunction woocommerce_template_loop_product_title() {echo '<h4 class="woocommerce-loop-product__title">' . get_the_title() . '</h4>'; }電流輸出期望的輸出
查看完整描述

3 回答

?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗 獲得超7個贊

function woocommerce_template_loop_product_title() {

global $product;

$price = $product->get_price_html();

echo '<h4 class="woocommerce-loop-product__title h-price">' . get_the_title() .'&nbsp'. $price .'</h4>';}

我的答案。


查看完整回答
反對 回復(fù) 2023-04-15
?
慕尼黑5688855

TA貢獻(xiàn)1848條經(jīng)驗 獲得超2個贊

您需要添加一個操作來更改標(biāo)題。所以我為您編寫了這段代碼,只需將其添加到您的 functions.php


add_action( 'the_title', 'add_price_title' );


function add_price_title($title) {

 $post_ID = get_the_ID();

 $the_post = get_post($post_ID);

 $date = $the_post->post_date;

 $maintitle = $the_post->post_title;

 $count='';

 $product = wc_get_product( $post_ID );

 $price = $product->get_price();



if ($the_post->post_status == 'publish' AND $the_post->post_type == 'product' AND in_the_loop()) { 

 return "<span type='number' class='notbold'>".$title." $".$price.""."</span>";

}


else{

 return $title;   

}

}


查看完整回答
反對 回復(fù) 2023-04-15
?
蕭十郎

TA貢獻(xiàn)1815條經(jīng)驗 獲得超13個贊

// define the woocommerce_shop_loop_item_title callback 

function action_woocommerce_shop_loop_item_title() { 

    // make action magic happen here... 

    global $product;

    echo '<p>'.get_post_meta($product->get_id(), '_price', true).'</p>';

}; 


// add the action 

add_action( 'woocommerce_shop_loop_item_title', 'action_woocommerce_shop_loop_item_title', 10 ); 



查看完整回答
反對 回復(fù) 2023-04-15
  • 3 回答
  • 0 關(guān)注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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