How to remove “Month:”, “Category:”, etc. on archive pages in WordPress

This section explains how to remove prefixes such as “Month:” and “Category:” that appear on WordPress archive pages. This is accomplished by using the get_the_archive_title filter hook to customize the title format.

The specific code is as follows

function custom_archive_title($title){ 
 $titleParts=explode(': ',$title); 
 if($titleParts [1] ){ 
 return $titleParts [1]; 
 } 
 return $title; 
} 
add_ filter('get_the_archive_title','custom_archive_title');

By adding this code to your theme’s functions.php file, you can remove prefixes such as “month:” and “category:” from the archive page title.

Leave a Comment

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

Scroll to Top