order archive page by title in wp twenty twenty-four template

admin2025-01-07  4

I have been trying to determine how to order the Archive page by Title in the WP Twenty Twenty-Four Template. I cannot find the parameters to do so. Can someone point me to where I can make that change? Thanks.

I have been trying to determine how to order the Archive page by Title in the WP Twenty Twenty-Four Template. I cannot find the parameters to do so. Can someone point me to where I can make that change? Thanks.

Share Improve this question edited Dec 12, 2024 at 14:44 mmm 3,7933 gold badges16 silver badges22 bronze badges asked Dec 12, 2024 at 14:24 beausoleil85beausoleil85 1
Add a comment  | 

1 Answer 1

Reset to default 1

The pre_get_posts filter can be used to change query parameters (untested):

add_action( 'pre_get_posts', static function ( $query ) {
    if ( is_admin() ) {
        return;
    }

    if ( ! $query->is_main_query() ) {
        return;
    }

    if ( ! $query->is_home() ) {
        return;
    }

    $query->set( 'orderby', 'title' );
} );
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736260810a692.html

最新回复(0)