我想在wordpress中重新安排我最近的帖子,这样它们就会升序/降序。
下面是我的代码:
<ul>
<?php query_posts('cat=3,4,5&posts_per_page=5&order=ASC'); foreach ($post as $post) ?>
<li>
<span class="date"><?php the_time('M j') ?></span>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>每个帖子都是从不同的类别中提取出来的。查看网站here
发布于 2010-05-01 02:59:53
为什么不使用标准的query_posts
<?php
//The Query
query_posts('cat=3,4,5&posts_per_page=5&order=ASC');
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
..
endwhile; else:
..
endif;
?>这段代码应该可以工作,如果您使用get_posts而不是query_posts的另一个原因,您的问题很可能是您的参数列表-在我看来,您将需要更改
get_posts('cat=3,4,5,numberposts=5&order=DESC&orderby=date')至
get_posts('cat=3,4,5&numberposts=5&order=DESC&orderby=date')因为&被用来分隔参数。
https://stackoverflow.com/questions/2746821
复制相似问题