How to remove the “Tag:” prefix from the tag title in the archive pages of a WordPress theme

To remove the “Tag:” prefix from the tag title in the archive pages of your WordPress theme, you can use the get_the_archive_title filter. Add the following code snippet to your theme’s functions.php file:

  1. In your WordPress admin dashboard, go to “Appearance” > “Theme Editor.”
  2. In the right sidebar, locate and click on the “functions.php” file.
  3. Add the following code snippet at the end of the file:
function my_theme_remove_tag_prefix($title) {
    if (is_tag()) {
        $title = single_tag_title('', false);
    return $title;
add_filter('get_the_archive_title', 'my_theme_remove_tag_prefix');

This code snippet creates a function called my_theme_remove_tag_prefix() that checks if the current page is a tag archive. If it is, the function replaces the full title with the tag title without the “Tag:” prefix using the single_tag_title() function.

  1. Click “Update File” to save the changes.

Now, the “Tag:” prefix should be removed from the tag titles on your tag archive pages.

Remember to always backup your files before making any changes, and test your changes on a staging site or local development environment before applying them to your live site.

Leave a Reply

Your email address will not be published. Required fields are marked *