Site logo

Archived topic

sort posts alphabetic

3 replies · Started by Torsten on October 13, 2022

Viewing posts 1–4 of 4

Hi,
hopefully the last question for this project:
Is it possible to sort the category posts only for the category-id18 "kuenstlerinnen" (category page link in Private information) in alphabetic order?
Thanks ahead,
Torsten

Hi there,

try this PHP Snippet:


function db_abc_modify_query_order( $query ) {
    if ( $query->is_category( 'your-category-slug' ) && $query->is_main_query() ) {
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
    }
}
add_action( 'pre_get_posts', 'db_abc_modify_query_order' );

Make sure to update the your-category-slug in the code

THANKS!

You're welcome

This archived topic is closed to new replies.