Categories
Wordpress

Remove Protected and Private title prefix

If you use Private or Password Protected posts or pages you might want to remove that awful title prefix

  • Private: …
  • Protected: …

To remove the title prefix you can simply add in your WordPress theme functions.php file, the following code

function the_title_trim($title)
{
  $pattern[0] = '/'.__('Protected').': /';
  $pattern[1] = '/'.__('Private').': /';
  $replacement[0] = ''; 
  $replacement[1] = ''; 
  return preg_replace($pattern, $replacement, $title);
}
add_filter('the_title', 'the_title_trim');

This code will remove the title prefix for Private and Password Protected pages and posts, independently by the language used in the WordPress installation.