admin管理员组

文章数量:1391937

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.

本文标签: wp queryorder by post date and modified date posts both in wpquery