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.

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

  1. 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

Leave a Reply