最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - order by post date and modified date posts both in wpquery

programmeradmin0浏览0评论

I am using a standard wp_query to load posts. My requirement is to display posts orderby post date and modified date both.

Which means if i added new post that also should show on top and if i modify any post that also should come on top.

How can this work?

 $the_query = new WP_Query( array(
     'post_type'   => $post_type,
     'orderby'     => 'modified',
     'order'       => 'DESC',
 ));

I am using a standard wp_query to load posts. My requirement is to display posts orderby post date and modified date both.

Which means if i added new post that also should show on top and if i modify any post that also should come on top.

How can this work?

 $the_query = new WP_Query( array(
     'post_type'   => $post_type,
     'orderby'     => 'modified',
     'order'       => 'DESC',
 ));
Share Improve this question asked Feb 11, 2020 at 21:24 SameerSameer 314 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Just go by the modified date.

WP sets both the published date and the modified date to the same time, when you publish a new post. So, the modified date will always have the most-recent date for every post - whether it's brand-new or an update.

发布评论

评论列表(0)

  1. 暂无评论