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

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

為什么wp_list_categories()會(huì)自動(dòng)插入到頁(yè)面頂部?

為什么wp_list_categories()會(huì)自動(dòng)插入到頁(yè)面頂部?

PHP
撒科打諢 2023-09-15 09:47:43
據(jù)說(shuō) wp_list_categories() 函數(shù)返回一個(gè)字符串。但是,它不會(huì)返回任何內(nèi)容,而是在另一個(gè)位置激活類(lèi)別列表的輸出。頁(yè)面內(nèi)容生成如下function build_index_posts(...){  $html = '';  $html.= '<div class="one">';  $html.= '<h1>'.$header_arr['title'].'</h1>';  $html.= '</div>';  return $html;} 我試圖輸出一個(gè)包含子類(lèi)別列表的塊,但它沒(méi)有插入到指定位置,而是插入到頁(yè)面的最開(kāi)頭。   function build_index_posts(...){      $html = '';      $html.= '<div class="one">';      $html.= '<h1>'.$header_arr['title'].'</h1>';      $html.= '</div>';          $category = get_queried_object();      $category_id = $category->term_id;                            $li_args = array(         'child_of' => $category_id,         'depth' => 1,          'style' => 'none',           'hide_empty' => 0,           'orderby'      => 'name',           'show_count'   => 0,           'pad_counts'   => 0,          'hierarchical' => 1,           'title_li'     => ''          );        $cat_list = wp_list_categories($li_args);        $cat_list = str_replace('<br>', '', $cat_list);                $html.= '<div style="display: none">';        $html.= $cat_list;  // NULL ??         $html.= '</div>';      return $html;    } 如何在適當(dāng)?shù)膲K中插入類(lèi)別列表?
查看完整描述

1 回答

?
萬(wàn)千封印

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

有兩種使用方法wp_list_categories()- 您使用它的方式將立即輸出代碼中調(diào)用它的列表 - 這就是您在頁(yè)面頂部看到它的原因。


如果您想獲取類(lèi)別列表作為變量,則需要傳遞包含echo值為false(默認(rèn)為 true)的參數(shù):


$li_args = array(

? ? ?'echo' => false,

? ? ? /* the rest of your args */

);


// now you can save the list in a variable.

$cat_list = wp_list_categories($li_args);

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

添加回答

舉報(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)