Removing Protected and Private from WordPress posts

By default WP will prepend Protected to any post title that is protected by a password and will prepend Private to any that is set as private, let's fix that.

By default WordPress will prepend the copy "Protected: " to any post title that is protected by a password and will prepend the copy "Private: " to any post title that is set as a private post.

I can see the sense in doing this, in a lot of cases you want to clearly mark those posts as such. In my use case though I am helping theme a site for a photographer, and all his client photos are password protected, in this case having the extra "Protected" copy just looks ugly.

Happily there is a really simple fix you can apply to kill this wording, add the following snippet to your theme's functions.php file.


function protect_my_privates($text){
  $text='%s';
  return $text;
}
add_filter('private_title_format','protect_my_privates');
add_filter('protected_title_format', 'protect_my_privates');

What this does is tells both private_title_format and protected_title_format that we just want to pass through the title and not append or prepend anything to it.

If you did want to do something special to the text you could always edit $text to be something like;


$text = '[protected]%s[/protected]'

This will make a title that is called "Hello World" appear like "[protected]Hello World[/protected]"

Recent posts View all

Reviews

TextExpander Review

In this TextExpander review I cover what it is and why I have been using it for years to be more productive.

Office 365

Office 365 Security

Office 365 is an incredibly popular product with some amazing security features