我试图按降序显示以下帖子,从第一篇创建的帖子开始,到最后一页以最近创建的帖子结束。非常感谢您的帮助。这是我的代码:
<?php
$numofmebers = \'-1\';
if ( empty($_GET[\'page_id_all\']) ) $_GET[\'page_id_all\'] = 1;
$count_post = 0;
query_posts( array( \'posts_per_page\' => \'-1\', \'post_type\' => \'coach-instructor\' ,\'post_status\' => \'publish\') );
while ( have_posts()) : the_post();
$count_post++;
endwhile;
if ( $node->instructor_pagination == "Single Page" ) {$node->instructor_page_num = -1;}
query_posts( array(\'posts_per_page\' => "$node->instructor_page_num", \'paged\' => $_GET[\'page_id_all\'], \'post_type\' => \'coach-instructor\' ,\'post_status\' => \'publish\') );
$counter_news = 0;
while ( have_posts()) : the_post();
$counter_news++;
$image_id = get_post_thumbnail_id ( $post->ID );
$coach_istructor_meta = get_post_meta($post->ID, "cs_coach_istructor_meta", true);
if ( $coach_istructor_meta <> "" ) {
$xmlObject_author = new SimpleXMLElement($coach_istructor_meta);
$about = $xmlObject_author->about;
$specialism = $xmlObject_author->specialism;
$qualifications = $xmlObject_author->qualifications;
$philosophy = $xmlObject_author->philosophy;
$contact = $xmlObject_author->contact;
}
else {
$about = \'\';
$specialism = \'\';
$qualifications = \'\';
$philosophy = \'\';
$contact = \'\';
}
?>
最合适的回答,由SO网友:Ed Burns 整理而成
请记住,最好避免使用query\\u posts,因为它会对主循环产生负面影响。更好的方法是创建WP\\u Query的新实例或更改主循环的查询参数。
要获取所需的订单,请尝试将以下内容添加到参数中:
array( \'posts_per_page\' => \'-1\', \'post_type\' => \'coach-instructor\' ,\'post_status\' => \'publish\', \'orderby\' => \'date\', \'order\' => \'ASC\')