How To Remove (Or Change) “Private” Or “Protected” From WordPress Post Titles

If you make a post private in WordPress, the post’s title with be prefixed with “Private”. The same will happen if you password protect the post, although it will be prefixed with “Protected”. If you’d like to remove these, just add the following code to your theme’s functions.php file:

add_filter( 'private_title_format', 'yourprefix_private_title_format' );
add_filter( 'protected_title_format', 'yourprefix_private_title_format' );

function yourprefix_private_title_format( $format ) {
	return '%s';
}

The above code will remove the prefix by changing the format from Private: %s and Protected: %s to just %s where %s is the existing post title.

If you’d like to change it to something else, you can just change what the function in my example returns. If you want to change them independently of each other, then you’ll need to use two separate callback functions.

18 thoughts on “How To Remove (Or Change) “Private” Or “Protected” From WordPress Post Titles

  1. Great tip, but I am afraid something is missing from the code… I encounter a 500 server error as soon as I add this to my functions.php file

  2. hey alex,
    I was wondering if you could help. how would I add this filter which works great by the way, to theme child functions.php? I’m getting errors when I try to use functions.php from the child theme dir.
    thanks in advance
    paul

  3. Pingback: WordPress: Private / Protected nicht anzeigen – datentraeger

Comments are closed.