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

Share:
  • Facebook
  • Twitter
  • Tumblr
  • LinkedIn
  • MySpace
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Yahoo! Buzz
  • Google Bookmarks
  • email
  • Posterous
This entry was posted in Website design, WordPress, WordPress tutorial and tagged , , . Bookmark the permalink.

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

  1. Madeglobal says:

    You could also try the plugin “better-protected-pages” available from http://www.wordpress.org/extend … hope that helps!

  2. TJM says:

    Unfortunately this doesn’t work in my case. Just get a bunch of parse errors “unexpected ….” on the password protected page. :(

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>