Want to display latest post by modified date on Static Homepage


Hello Everyone,

I want to show the lastest modified/updated posts first at my homepage…

Currently, it’s showing the latest post (New Posts which I add) not the updated posts…

I have added a link at the top (View today Updated posts, which shows the latest and update posts both) I want them to show on my homepage.

For better understanding kindly check at allcrackapk (.) com

Plz help


You can change post order

// Sort by last modified
function modified( $query )
    if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() )  )
        $query->set( 'orderby', 'modified' );
        $query->set( 'order', 'desc' );
add_action( 'pre_get_posts', 'modified' );

Where I need to replace this code?


Install and activate Code Snippets plugin. Then, add a new snippet with above one.


its not working