我想使用插件可湿性粉剂智能排序按字母顺序排序我的帖子,除非我需要在主页上首先张贴最近的帖子。主页的相关现有代码如下所示。有没有什么我可以添加的东西,强制它包含最近的帖子,并按照日期而不是我想要的字母顺序在其他地方?
(如果它有助于了解上下文,请访问http://mormonscholarstestify.org/)
<div id="homebox">
<?php if ($aOptions['homebox-id'] != '') { query_posts('showposts=5&cat=' . $aOptions['homebox-id']); } ?>
<?php if(have_posts()) : the_post() ?>
<div id="boxmain">
<a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><img src="<?php $key="thumbnail"; echo get_post_meta($post->ID, $key, true); ?>" alt="<?php the_title() ?>" /></a>
<h3><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_title() ?></a></h3>
<?php $key="affiliation"; echo get_post_meta($post->ID, $key, true); ?><p>
<?php the_excerpt(); ?>
</div>
<?php endif; ?>
<?php while(have_posts()) : the_post() ?>
<div class="boxitem">
<a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><img src="<?php $key="thumbnail"; echo get_post_meta($post->ID, $key, true); ?>" alt="<?php the_title() ?>" /></a>
<h3><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_title() ?></a></h3>
<?php $key="affiliation"; echo get_post_meta($post->ID, $key, true); ?>
</div>
<?php endwhile; ?>
</div>发布于 2010-05-25 21:22:11
根据Wordpress query_posts documentation,您应该能够向查询字符串提供一个orderby参数来更改帖子的排序方式,如下所示:
query_posts('showposts=5&orderby=date&order=ASC&cat=' . $aOptions['homebox-id']);https://stackoverflow.com/questions/2904904
复制相似问题