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

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

如何從 WordPress 的分類(lèi)中獲取帖子?

如何從 WordPress 的分類(lèi)中獲取帖子?

PHP
呼喚遠(yuǎn)方 2023-10-15 17:15:51
所以我有一個(gè)名為(“knowledge_base”)的自定義類(lèi)型,它有一個(gè)名為(“section”)的分類(lèi)法,其中之一是(“狗咬”)?,F(xiàn)在我在 example.com/section/dog-bite/ 上,我正在嘗試顯示此處的帖子。這是我到目前為止所擁有的,所以我不確定缺少什么,但它只顯示所有部分的所有帖子。$current = get_queried_object(); $args = array(        'post_type' => 'knowledge_base',        'tax_query' => array(            array(             'taxonomy'  => 'section',             'field'    => $current->slug,             'terms'    => $current->name             )         )       ); // The Query $the_query = new WP_Query( $args );if ( $the_query->have_posts() ) {     echo '<ul>';     while ( $the_query->have_posts() ) {         $the_query->the_post();         echo '<li>' . get_the_title() . '</li>';     }     echo '</ul>'; } else {     // no posts found }應(yīng)該只有2個(gè)帖子
查看完整描述

1 回答

?
慕姐4208626

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

檢查此代碼。


$args = array(

    'post_type' => 'knowledge_base',

    'tax_query' => array(

        array(

            'taxonomy'  => 'section',

            'field'    => 'slug', // ‘term_id’, ‘name’, ‘slug’ or ‘term_taxonomy_id’

            'terms'    => $current->slug, // It's will be $term->slug

        )

    )

);

// The Query

$the_query = new WP_Query( $args );


if ( $the_query->have_posts() ) {

    echo '<ul>';

    while ( $the_query->have_posts() ) {

        $the_query->the_post();

        echo '<li>' . get_the_title() . '</li>';

    }

    echo '</ul>';

}


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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