Home › Forums › Support › posts ordered by last modified date This topic has 4 replies, 2 voices, and was last updated 4 years ago by David. Viewing 5 posts - 1 through 5 (of 5 total) Author Posts March 7, 2019 at 12:39 am #831326 Xiaowei function wzj_order_by_last_modified( $query ) { if($query->is_main_query() AND !is_admin() ) { if ( $query->is_home() || $query->is_category() || $query->is_tag() ){ $query->set( 'orderby', 'modified' ); $query->set( 'order', 'DESC' ); } } } add_action( 'pre_get_posts', 'wzj_order_by_last_modified' ); Above code doesn’t work, I’m not sure if it’s GeneratePress or myself missing something. GeneratePress 2.2.2 March 7, 2019 at 2:48 am #831452 DavidStaff Customer Support Hi there, the code looks ok. I think the problem is that your posts do not have any modified date applied, there is not meta tags for these in the posts Documentation: http://docs.generatepress.com/ Adding CSS: http://docs.generatepress.com/article/adding-css/ March 7, 2019 at 2:55 am #831461 Xiaowei The posts do have modified date applied, I queried wp_post table. March 7, 2019 at 4:01 am #831503 Xiaowei My bad, I ticked a post as featured and stick to the top. That’s why sorting by last modified didn’t work. March 7, 2019 at 4:02 am #831505 DavidStaff Customer Support Aah good find – thanks for reporting back. Glad you got it resolved. Documentation: http://docs.generatepress.com/ Adding CSS: http://docs.generatepress.com/article/adding-css/ Author Posts Viewing 5 posts - 1 through 5 (of 5 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In