Easy steps to change the posts order in WordPress Blog
You can ether install a plugin like https://wordpress.org/plugins/custom-post-order/
or add the next lines in the function.php file from your wordpress theme.
add_filter ( 'posts_orderby', 'custom_posts_order', 99, 1);
function custom_posts_order( $orderby) {
if (is_category()){
return 'post_modified DESC';
}
}

I’ve changed the custom order from ‘post_date DESC’ to ‘post_modified DESC’ to have the latest modified articles in front.
Notice that I’ve added the category condition ‘is_category’ which will change the posts order just for categories and not for tags or other terms.
Hope this helps.
Next read: Installing Squirrly SEO Plugin on a new site


0 Comments