Remove Private prefix from wordpress private pages titles

April 1, 2010 · Print This Article

We had the situation come up where we need a password-protected post in WordPress. Of course that is super easy in WordPress, you can set up a password for it right in the “Publish” box before publishing. But by default, WordPress appends “Protected: ” to the front of the post title, before and after the password has been entered. Maybe you didn’t like that, and thought that the password box was clue enough that the material was password protected.

To remove theses private prefix, simply open your functions.php file and paste the following code:

function the_title_trim($title) {
$title = attribute_escape($title);
$findthese = array(
'#Protected:#',
'#Private:#'
);
$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');


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.