Order of subcategories

Question

Hello,
I use the code below to list the subcategories on parent category pages. But it does not list the categories in alphabetical order. Can you change this code for me so that it can list the subcategories alphabetically?

/ list subcategories...
function wpse_filter_child_cats( $query ) {

if ( $query->is_category ) {
    $queried_object = get_queried_object();
    $child_cats = (array) get_term_children( $queried_object->term_id, 'category' );

    if ( ! $query->is_admin )
        //exclude the posts in child categories
        $query->set( 'category__not_in', array_merge( $child_cats ) );
    }

    return $query;
}
add_filter( 'pre_get_posts', 'wpse_filter_child_cats' );```
0
loloist 8 months 2020-12-01T15:10:20-05:00 0 Answers 17 views 0

Leave an answer

Browse
Browse