[英]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.