Category Archive Layout Sort By Modified Date

Hi,

Is it possible to sort the posts in a Category Archive Layout by modified date instead of the default created date? The posts are being provided by the Looper Consumer.

Thanks,
Christopher

Hello Christopher,

Thanks for writing to us.

Regretfully there is no option to set the order on the post on the category achieve layout when you are using the default looper consumer. Please note you need to use the Looper provider then you can set the post order but if you would use the Looper Provider there on the achieve layout then the Pagination element would not work.

Achieving this feature would require custom development, I would suggest you please contact a developer who can assist you with your concerns or you may subscribe to One where customization questions are answered. Please note we don’t provide custom development support. It is out of the support scope.

Hope it helps
Thanks for understanding

Hi Prakash,

That is what I suspected the case would be. Not a problem and thank you for confirming. I have got around the issue by adding an action to functions.php:

function sort_posts_by_modified_date( $query ) {
    if( $query->is_main_query() && ! is_admin() && ( $query->is_archive() ) ) {
        $query->set( 'orderby', 'modified' );
        $query->set( 'order', 'DESC' );
    }
}

add_action( 'pre_get_posts', 'sort_posts_by_modified_date' );

Thanks again,
Christopher

Hello @whitemedia,

Thanks for sharing the information, glad that you were able to create custom code for your customization. Please feel free to open a new thread if you have any more concerns.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.