By default, WordPress sorts blog posts by creation date. However, if you update your blog posts from time to time, you may want to sort them by modification date rather than creation date.
To achieve this, use this snippet:
function order_posts_by_mod_date($orderby) { if (is_home() || is_archive() || is_feed()) { $orderby = "post_modified_gmt DESC"; } return $orderby; } add_filter('posts_orderby', 'order_posts_by_mod_date', 999);
In your theme, just dump this snippet into functions.php
. (You may need to create this file in your theme’s directory.)
Works well. Tnanks!
thanks a lot, it works..
It works great, Ive been looking EVERYTHING on the internet for the answer, after 50 different results, nothing. Thank you so much for this!
Thank You SO MUCH!
God bless you !
Thank you so much. The code works really well on my wordpress site. I also replaced the creation date -> modified date in the entry-meta.
Thanks you
It has solved my problem
Thank you so much. This saved me hours and hours of searching. It works well on my site.
Thanks That worked for me
Pingback: WordPress Sort Posts by Modification Date -
Cool!
Great, its work