Php 在wordpress中按ASC顺序显示最新帖子
我想得到最新的帖子 这在结果字符串显示中类似Php 在wordpress中按ASC顺序显示最新帖子,php,wordpress,Php,Wordpress,我想得到最新的帖子 这在结果字符串显示中类似 12th Jul 2015 24th Mar 2015 18th Jan 2015 我想把它展示得像 18th Jan 2015 24th Mar 2015 12th Jul 2015 我有一个查询字符串 <?php query_posts(array( 'cat' => '17', 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 3
12th Jul 2015
24th Mar 2015
18th Jan 2015
我想把它展示得像
18th Jan 2015
24th Mar 2015
12th Jul 2015
我有一个查询字符串
<?php query_posts(array( 'cat' => '17', 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 3 ) ); ?>
提前感谢…我认为这是可行的:
<?php
$myposts = get_posts('cat=3&showposts=3');
if ($myposts) {
$uc=array();
foreach ($myposts as $mypost) {
$uc[]=$mypost->ID;
}
}
$args=array(
'post__in' => $uc,
'orderby' => 'post_date',
'order' => 'ASC',
'posts_per_page' => 3,
'caller_get_posts' => 1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'Category 3, lastest posts, sorted oldest to newest';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><small><?php the_time('m.d.y') ?> </small><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
} //if ($my_query)
wp_reset_query(); // Restore global post data stomped by the_post().
?>
是的,但ASC给了我最老的帖子,我想要最新的3篇,并按升序排列,在问这个问题之前,我已经尝试了很多。:)我想你需要阅读这个降序的意思是先是最新的,或是最大的数字,然后下降到越来越老。因此,要实现您想要使用的ASC(升序)。如果这根本不起作用,那么失败的更多是你的代码。该链接还将向你显示,你基本上永远不应该使用query\u posts()
。我正在尝试使用该链接解决我的问题,并且@oBo该查询正在起作用,但我希望最新的3篇文章按升序排列,而查询将最新的3篇文章按降序排列。