How to customize the_archive_title()?

If you look at the source code of get_the_archive_title(), you will see that there is a filter supplied, called get_the_archive_title, through which you can filter the output from the function.

You can use the following to change the output on a category page

add_filter( 'get_the_archive_title', function ( $title ) {

    if( is_category() ) {

        $title = single_cat_title( '', false );

    }

    return $title;

});

Leave a Comment