Remove private label in wordpress post title

Looking for a way to remove the private or protected prefix from post title? This snippet removes the description prepended to the post title when posts are either Password Protected or Private.

Put this code in the functions.php file of your theme:

function the_title_trim($title) {

	$title = attribute_escape($title);

	$findthese = array(

	$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');
Posted in

Leave a Comment