Removing “Private” and “Protected” from WordPress post titles

Here is a great snippet of code that removes “Private” and “Protected” from your password protected posts in WordPress. Just drop it into your functions.php file.

function the_title_trim($title)


$title = attribute_escape($title);

$findthese = array( ‘#Protected:#’, ‘#Private:#’ );

$replacewith = array( ”, // What to replace “Protected:” with ” // What to replace “Private:” with );

$title = preg_replace($findthese, $replacewith, $title);

return $title;


add_filter(‘the_title’, ‘the_title_trim’);

Credit for this great chunk of code goes to Chris Coyier.

Leave a Reply