Wordpress - 首先强制发布最新帖子

时间:2010-05-25 13:11:56

标签: wordpress sorting

我想使用插件WP Smart Sort按字母顺序对帖子进行排序,除了我需要在主页上首先发布的最新内容。主页的相关现有代码如下。我可以添加一些内容来强制它包含最近的帖子并按日期而不是按照我想要的其他字母顺序排列吗?

(如果有助于查看上下文,则网站位于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>

1 个答案:

答案 0 :(得分:1)

根据Wordpress query_posts documentation,您应该能够为查询字符串提供orderby参数,以更改帖子的排序方式,如下所示:

query_posts('showposts=5&orderby=date&order=ASC&cat=' . $aOptions['homebox-id']);