[英]Wordpress/PHP: Can't get WordPress posts to order by year/date
我已经按年份对帖子进行了分组...但是它首先显示最早的年份,例如2013年而不是2015年...
2013 2014 2015
它应该是
2015 2014 2013
这是代码:
$year_check = date('Y', strtotime($post->post_date));
if($year_tmp!==$year_check){
$year_tmp = $year_check;
if($postsShown > 0){
echo '</div>';
}
echo '<div class="seperator"></div><a href="#" class="datecolumn" id="date_col_'.$year_check.'">'.$year_check.'<div class="expand" id="expand_'.$year_check.'">CLOSE</div></a><div class="seperator"></div><div class="ruler"></div><div class="seperator"></div><div class="yearBlock" id="'.$year_check.'">';
}
$date = date('jS F Y', strtotime($post->post_date));
echo '<a class="standardColumnLink" href="'.get_permalink($post->ID).'" title="'.$thetitle.'">';
if(!empty($thethumb)){
echo '<div class="standardColumnImage">'.$thethumb.'</div>';
}
echo '<div class="columncopy"><div class="narrowcolumn">→</div><div class="titles">'.$thetitle.'</div><div class="columnbody">'.get_excerpt_by_id(get_the_ID()).'</div><div class="columdate"><strong>Date posted:</strong> '.$date.'</div></div></a>';
if($year_tmp!==$year_check){
echo '</div>';
}
您是完全正确的,这是我的查询逻辑...我将orderby更改为DESC并成功了。
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.