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
1 Answer
Reset to default 0Just 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.