[英]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.