繁体   English   中英

如何在WordPress中按不同日期手动排序帖子?

[英]How to sort Posts manually by different date in WordPress?

我有一个wordpress类别存档,用于“ press”类别中的帖子。 当前,每个类别帖子均按WordPress发布日期排序。 现在,每个帖子还具有一个“ Press Date ”( 按日期 )字段,该字段使用户可以按月年份格式(如“ May 2012”

我想根据此发布日期对帖子进行排序。 这是我当前的代码:

<?php query_posts('showposts=10000&cat=3'); if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
        <? $count = $count + 1; $clear = $count % 6; ?>
        <a <? post_class("press-block"); ?> href="<? echo get('link');?>" target="_blank">
            <? echo get_image ('press_image')  ?>
            <span class="press-info">
                <? the_title(); ?>
                <span><? echo get('publication_title'); ?></span>
                <span><? echo get('press_date');?></span>
            </span>
        </a>
    <?php endwhile;  ?>

<?php else : ?>
    No Posts Found
<?php endif; wp_reset_query(); ?>

要使用自定义字段/元值来排序query_posts result ,可以使用

query_posts('showposts=10000&cat=3&orderby=meta_value&meta_key=press_date'); // name of 'Press Date' field

有关更多信息,请参见Order&Orderby参数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM