Using WordPress ‘get_the_archive_title_prefix’ PHP filter

The get_the_archive_title_prefix WordPress PHP filter allows you to modify the archive title prefix.

Usage

add_filter( 'get_the_archive_title_prefix', 'your_custom_function' );

function your_custom_function( $prefix ) {
    // your custom code here
    return $prefix;
}

Parameters

  • $prefix (string) – Archive title prefix.

More information

See WordPress Developer Resources: get_the_archive_title_prefix

Examples

Remove the Archive Title Prefix

To remove the archive title prefix altogether, return an empty string.

add_filter( 'get_the_archive_title_prefix', 'remove_archive_title_prefix' );

function remove_archive_title_prefix( $prefix ) {
    return '';
}

Change Archive Title Prefix for Categories

To change the archive title prefix for category archives, use the following code:

add_filter( 'get_the_archive_title_prefix', 'change_category_archive_prefix' );

function change_category_archive_prefix( $prefix ) {
    if ( is_category() ) {
        $prefix = 'Category: ';
    }
    return $prefix;
}

Change Archive Title Prefix for Tags

To change the archive title prefix for tag archives, use the following code:

add_filter( 'get_the_archive_title_prefix', 'change_tag_archive_prefix' );

function change_tag_archive_prefix( $prefix ) {
    if ( is_tag() ) {
        $prefix = 'Tagged: ';
    }
    return $prefix;
}

Change Archive Title Prefix for Custom Post Types

To change the archive title prefix for custom post type archives, use the following code:

add_filter( 'get_the_archive_title_prefix', 'change_custom_post_type_archive_prefix' );

function change_custom_post_type_archive_prefix( $prefix ) {
    if ( is_post_type_archive() ) {
        $prefix = 'Post Type: ';
    }
    return $prefix;
}

Add Custom Prefix for Author Archives

To add a custom prefix for author archives, use the following code:

add_filter( 'get_the_archive_title_prefix', 'add_author_archive_prefix' );

function add_author_archive_prefix( $prefix ) {
    if ( is_author() ) {
        $prefix = 'Author: ';
    }
    return $prefix;
}