简体   繁体   English

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

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

I have a wordpress category archive for posts in the "press" category. 我有一个wordpress类别存档,用于“ press”类别中的帖子。 Each category post is currently sorted by the WordPress publish date. 当前,每个类别帖子均按WordPress发布日期排序。 Right now each post also has a " Press Date " field which lets the user post a date in a month year format like "May 2012" 现在,每个帖子还具有一个“ Press Date ”( 按日期 )字段,该字段使用户可以按月年份格式(如“ May 2012”

I would like to sort the posts based on this Press Date instead. 我想根据此发布日期对帖子进行排序。 Here is my current code: 这是我当前的代码:

<?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(); ?>

To use custom fields/meta values to order the query_posts result you can use 要使用自定义字段/元值来排序query_posts result ,可以使用

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

For more see Order & Orderby Parameters . 有关更多信息,请参见Order&Orderby参数

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

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