WordPress Snippets at WPcustoms

Modify “Category:” from the_archive_title

This function jumps into the hook the_archive_title to help you to modify the default output from archive pages titles


/**
 * Snippet Name: Modify “Category:” from the_archive_title
 * Snippet URL: https://wpcustoms.net/snippets/modify-category-from-the_archive_title/
 */
  add_filter( 'get_the_archive_title', function ($title) {

    if ( is_category() ) {

            $title = single_cat_title( '', false );
            // $title = single_cat_title( 'customize the text demo', false );

        } elseif ( is_tag() ) {

            $title = single_tag_title( '', false );

        } elseif ( is_author() ) {

            $title = '' . get_the_author() . '' ;

        }

    return $title;

});