Comments LazyBit started the conversationAugust 21, 2021 at 4:45amHi dev, I would like to change last posts' sorting from published to modified on home and category pages. Can be done without using any plugin? 2,613PenciDesign repliedAugust 21, 2021 at 5:35amHi,You can change this via Appearance → Customize → General → General Setting, check Display Modified Date Replace with Published Date.Regards,PenciDesign.LazyBit repliedAugust 21, 2021 at 5:43amHi, As far as I can see that option just change which info is displayed. I would like posts to be sorted by modified date (last update) instead of by publish date. 2,613PenciDesign repliedAugust 21, 2021 at 5:48amHi, Please install the Code Snippet plugin then create a new snippet with the following content: function lazybit_orderby_modified_posts( $query ) { if( $query->is_main_query() && !is_admin() ) { $query->set( 'orderby', 'modified' ); $query->set( 'order', 'desc' ); } } add_action( 'pre_get_posts', 'lazybit_orderby_modified_posts' ); Regards,PenciDesign. LazyBit repliedAugust 21, 2021 at 5:53amWorks good, thank you! Sign in to reply ...
Hi dev,
I would like to change last posts' sorting from published to modified on home and category pages. Can be done without using any plugin?
Hi,
You can change this via Appearance → Customize → General → General Setting, check Display Modified Date Replace with Published Date.
Regards,
PenciDesign.
Hi,
As far as I can see that option just change which info is displayed. I would like posts to be sorted by modified date (last update) instead of by publish date.
Hi,
Please install the Code Snippet plugin then create a new snippet with the following content:
Regards,
PenciDesign.
Works good, thank you!