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

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

如何顯示多個連續(xù)的html元素

如何顯示多個連續(xù)的html元素

PHP
梵蒂岡之花 2021-05-05 21:34:09
我在我的wordpress網(wǎng)站上使用ACF在搜索欄中顯示HTML文本,該文本位于基于該posts數(shù)組值的帖子標(biāo)題旁邊?,F(xiàn)在,腳本最多只能顯示html值之一,但是我希望它包括所有存在的html值。add_filter( 'asp_results', 'asp_custom_field_to_results', 10, 1 ); function asp_custom_field_to_results( $results ) {  $custom_field = 'trade_status';   foreach ($results as $k=>&$r) {    if ($r->content_type != 'pagepost') continue;    if ( function_exists('get_field') )        $trade_status  = get_field( $custom_field, $r->id, true ); // ACF support    else        $trade_status  = get_post_meta( $r->id, $custom_field, true );    // Modify the post title to add the meta value    if ( !empty($trade_status) ) {      if ( in_array('30', $trade_status) ) {        $html = '<span class="new">New</span>';      } else if ( in_array('20', $trade_status) ) {        $html = '<span class="active">Active</span>';      } else if ( in_array('10', $trade_status) ) {        $html = '<span class="closed">Closed</span>';      } else {        $html = '';      }      $r->title = $html . $r->title;    }  }  return $results;}
查看完整描述

1 回答

?
慕后森

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

因此,看起來現(xiàn)在您正在為循環(huán)中的每個匹配迭代覆蓋$ html的值。我的猜測是,在執(zhí)行此操作時,您想連接(。=)而不是覆蓋(=)。


查看完整回答
反對 回復(fù) 2021-05-21
  • 1 回答
  • 0 關(guān)注
  • 217 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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