簡體   English   中英

如何按“標題”順序顯示wordpress帖子

[英]how to display wordpress posts by order “title”

我使用此功能來獲取帶有子naruto_chapitre_005的類別的帖子

$myposts = get_posts(array(
    'showposts' => -1,
    'post_type' => 'post',
    'tax_query' => array(
        array(
        'taxonomy' => 'category',
        'field' => 'slug',
        'terms' => array('naruto_chapitre_005'))
    ))
);



foreach ($myposts as $mypost) {
      echo $mypost->post_title . '<br/>';
}

//output
04
01
05
02
03

如何按訂單獲取職位? 像這樣01 02 03 04 05

嘗試這個

$myposts = get_posts(array(
        'posts_per_page' => -1,
        'post_type' => 'post',
        'order'     => 'ASC',
        'orderby'   => 'title',
        'tax_query' => array(
            array(
            'taxonomy' => 'category',
            'field' => 'slug',
            'terms' => array('naruto_chapitre_005'))
        ))
    );

orderby屬性與值title

   $myposts = get_posts(array(
            'posts_per_page' => -1,
            'post_type' => 'post',
            'order'     => 'ASC',
            'orderby'   => 'title',
            'tax_query' => array(
                array(
                'taxonomy' => 'category',
                'field' => 'slug',
                'terms' => array('naruto_chapitre_005'))
            ))
        );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM