[英]Wordpress category sort by date
I would like to sort my post in specyfic category ASC by date. 我想按日期对我在特殊类别ASC中的帖子进行排序。 My code is:
我的代码是:
<?php $cat_id = 3; //the certain category ID
$latest_cat_post = new WP_Query( array('posts_per_page' => 4, 'category__in' => array($cat_id)));
if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post(); ?>
<?php the_post_thumbnail('thumbnail', array('class' => 'thumbnailmini')); ?>
<h3><?php the_title(); ?></h3>
<?php the_content('więcej ->'); ?>
<div class="clear"></div>
<?php endwhile; endif; ?>
This code display 4 posts from category "3". 该代码显示类别“ 3”中的4个帖子。 How to sort this posts?
该帖子如何排序? I found:
我发现:
<?php query_posts ('cat=3&orderby=date&order=ASC'); ?>
but it doesn't work. 但这不起作用。
Regards. 问候。
try this,, 尝试这个,,
<?php $cat_id = 3; //the certain category ID
$latest_cat_post = new WP_Query( array('posts_per_page' => 4,'orderby' => 'date','order' => 'ASC', 'category__in' => array($cat_id)));
if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post(); ?>
<?php the_post_thumbnail('thumbnail', array('class' => 'thumbnailmini')); ?>
<h3><?php the_title(); ?></h3>
<?php the_content('wiecej ->'); ?>
<div class="clear"></div>
<?php endwhile; endif; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.