WordPress Tutorial – Remove the Word “Protected:” from Title Text of Password-protected Pages

Remove the word “Protected:” from title text of password-protected pages.

Big thanks to t31os on the WordPress forums. Check out t31os’s site for more WordPress tips.

The following filter function code is placed in the functions.php file, this way it doesn’t accidentally get replaced when WordPress is upgraded.

<?php
function the_title_trim($title)
{
$pattern[0] = ‘/Protected:/’;
$pattern[1] = ‘/Private:/’;
$replacement[0] = ”; // Enter some text to put in place of Protected:
$replacement[1] = ”; // Enter some text to put in place of Private:

return preg_replace($pattern, $replacement, $title);
}
add_filter(‘the_title’, ‘the_title_trim’);
?>

NOTE: I had to remove the *<?php* and *?>* tags from the above code and place the function code inside my existing *<?php* and *?>* tags that were already in my functions.php file. Otherwise, it messed up my Multi-level Navigation Plugin for WordPress (which I’m a big fan of).

WordPress version: 2.8.1 RC1

2 thoughts on “WordPress Tutorial – Remove the Word “Protected:” from Title Text of Password-protected Pages”

  1. Unfortunately this doesn’t work in my case. Just get a bunch of parse errors “unexpected ….” on the password protected page. ๐Ÿ™

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top