Remove Private/Protected from WordPress post title

WordPress adds the words ‘Private’ and ‘Protected’ to titles of private and password-protected posts. I don’t find it very appealing to have the word ‘Protected’ or ‘Private’ in the post titles. Do you want to remove ‘Private/Protected’ from WordPress posts and pages? Paste the following snippet in your theme’s functions.php file to remove words from post titles. If you want to replace the words with something of your own, you can add them by customising the snippet. By default, it is blank to delete the word altogether. If your language is not English, you can replace Protected & Private with the corresponding words in your language.

function the_title_trim($title) {
	$title = attribute_escape($title);
	$findthese = array(
		'#Protected: #', // Notice the blank space after Protected:
		'#Private: #' // Notice again, otherwise the title get pushed.
	);
	$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');