N
N
nulledbox2020-06-19 22:56:35
WordPress
nulledbox, 2020-06-19 22:56:35

How to sort by updating records?

I'm moving from DLE to WordPress and faced such a problem, after updating the post (adding text or changing it), the post remains the same as it was last week's date. But in DLE, the date + time is set at the time the record is updated - which is convenient and the record itself rises to the very top.

How can this be done in WordPress. So that, by default, topic entries are sorted by date + time of modification.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Ermilov, 2020-06-23
@sergeiermilov

A simple solution to sort by date modified is:

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question