Blog order by modified date

Hello,
I am using the Pro Theme and would like to sort blog posts globally—by default—based on the modification date. How can I do this? Is it possible to hook into cs_looper_set_args using a function?
Best regards,
Hannes

Hello Hannes,

Thanks for writing to us.

Regretfully, there is no option for that at the moment, as it would require custom development support. I would suggest contacting a developer who can assist you with your concerns or subscribing to One, where customization questions are answered. Please note that we do not provide custom development support, as it is outside our support scope.

Thanks for understanding

Thank you. What about this code snippet?

function pro_theme_native_archive_modified_sort( $query ) {
    // Ausschließliche Modifikation im Frontend und nur für die primäre Hauptabfrage
    if ( ! is_admin() && $query->is_main_query() ) {
        
        // Zielgerichteter Filter für die Standard-Beitrags-Archive
        if ( $query->is_home() || $query->is_category() || $query->is_tag() || $query->is_archive() ) {
            $query->set( 'orderby', 'modified' );
            $query->set( 'order', 'DESC' );
        }
    }
}
add_action( 'pre_get_posts', 'pro_theme_native_archive_modified_sort', 99 );

Hello Hannes,

The given code changes the default sorting order of WordPress archive pages so posts are displayed by their last modified date instead of their publish date.

Thanks

That is exactly what I wanted to achieve.

Hello Hannes,

Glad that you were able to find a solution to your query on your own.

Thanks

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