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

Web DevProductivity

Keeping on top of website updates

Learn what website updates are, what they entail, why they are important, and how we can help

Freelancing

Getting the most out of your agency

Here are some tips based on years of working with, for, and as an agency on how to get the most out of any work you do.