How to remove the “Archive | ” text from the archive title in WordPress

To remove the “Archive | ” text from the archive title in WordPress, 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 remove_archive_label($title) {
if (is_category()) {
$title = single_cat_title('', false);
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_author()) {
$title = '<span class="vcard">' . get_the_author() . '</span>';
} elseif (is_post_type_archive()) {
$title = post_type_archive_title('', false);
} elseif (is_tax()) {
$title = single_term_title('', false);
}

return $title;
}
add_filter('get_the_archive_title', 'remove_archive_label');

This code snippet creates a function called remove_archive_label() that removes the “Archive | ” prefix from the archive title for various archive types (categories, tags, authors, custom post types, and taxonomies).

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

Now, the “Archive | ” prefix should be removed from the archive titles on your WordPress site.

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 *