<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 輸入當前頂級分類的子分類 > 使用wordpress建網站時,在側邊欄往往需要調用某個當前頂級分類下的子分類,這樣只要在網站后臺添加分類后,網站界面就會自動的調用顯示出來。 > 本內容來自網絡分享,以下為原文鏈接: > @link [https://www.xuewangzhan.net/wpbbs/6770.html](https://www.xuewangzhan.net/wpbbs/6770.html) ![](https://img.kancloud.cn/ab/f9/abf9ff0db50cd1bf01ec82b2d00a8974_418x98.png) ## 在function.php中加入如下代碼: ``` /** * 獲取當前欄目的頂級欄目。 * 獲取當前頂級分類下的子分類。 * * @link https://blog.csdn.net/weixin_33985507/article/details/91900600 * @link https://www.seo628.com/2547.html * * 用法實例 * <?php if(get_category_children(get_category_root_id(the_category_ID(false)))!= "" ){ echo '<ul>'; echo wp_list_categories("child_of=".get_category_root_id(the_category_ID(false)). "&depth=0&hide_empty=0&title_li=&orderby=id&order=ASC"); echo '</ul>'; } ?> * */ function get_category_root_id($cat){ $this_category = get_category($cat); // 取得當前分類 while($this_category->category_parent){ // 若當前分類有上級分類時,循環 $this_category = get_category($this_category->category_parent); // 將當前分類設為上級分類(往上爬) } return $this_category->term_id; // 返回根分類的id號 } ``` ## 實際運用舉例(在邊欄sidabar.php中加入如下代碼) ``` <?php if(get_category_children(get_category_root_id(the_category_ID(false)))!= "" ){ echo '<ul>'; echo wp_list_categories("child_of=".get_category_root_id(the_category_ID(false)). "&depth=0&hide_empty=0&title_li=&orderby=id&order=ASC"); echo '</ul>'; } ?> ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看