query_posts(array(
'post_category' => 'xyz',
'post_type' => 'abc',
'posts_per_page' =>'16',
'paged'=> $paged,
'orderby' => 'post_title',
'order' => 'ASC'
));
我想根据帖子的标题按升序排序提取的记录。 当我使用
打印结果时echo 'query : '.$GLOBALS['wp_query']->request;
我注意到字段顺序是post_date
我已粘贴以下查询:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (7) ) AND wp_posts.post_type = 'abc' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC LIMIT 0, 16
答案 0 :(得分:1)
它应该与get_posts()
:
$args = array(
'category' => 'xyz',
'post_type' => 'abc',
'posts_per_page' =>16,
'orderby' => 'title',
'order' => 'ASC'
);
$myposts=get_posts($args);
echo '<ul>';
foreach($myposts as $post){ setup_postdata( $post );
echo '<li>'.get_the_title().'</li>';
}
wp_reset_postdata();?>
echo '</ul>';
但我不确定'paged'=> $paged,
是什么。
答案 1 :(得分:0)
我找到了答案,应该是:
query_posts(array(
'post_category' => 'xyz',
'post_type' => 'abc',
'posts_per_page' =>'16',
'paged'=> $paged,
'orderby' => 'title',
'order' => 'ASC'
));