
Each time you define a specific post as being private or password-protected, WordPress automatically add “Private” or “Protected” to your blog post title. If you don’t want it, nothing simpler: Just apply this great hack.

Each time you define a specific post as being private or password-protected, WordPress automatically add “Private” or “Protected” to your blog post title. If you don’t want it, nothing simpler: Just apply this great hack.
The only thing you have to do is to paste the following piece of code in your functions.php file. Once you'll save the file, the hack will be applied to your your posts.
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');
Credits goes to Chris Coyier for this awesome piece of code. Have you checked out the book Chris wrote with Jeff Starr? It's called Digging into WordPress and it is a must-have for all WordPress fans!
Personal announcement, I'm selling the webdev.fm domain name for only $50. Just send me an email if you want it!
8 Responses
Here’s another shorter way of removing them:
add_filter(‘protected_title_format’, ‘no_title_prefix’);
add_filter(‘private_title_format’, ‘no_title_prefix’);
function no_title_prefix( $prefix ) {
return ‘%s’;
}
Simon, that’s a good one.
Yes i have one “Digging into WordPress” book and it is very useful. It covers almost everything from installing WP through development. The spiral bound is a nice and practical feature.
I also like to cook with WpRecipes : )
Cheers
Very helpful post, thank a lot
Please remember to include a credit back to the originator or source of the artwork you use with your articles.
http://www.flickr.com/photos/subcircle/500995147/
worked great, i had to chanche “private” for “privado” ’cause my wordpress is in Spanish but it worked!
thanks!
Forgive me, but where exactly in the functions.php should this go? I added at the end and just see it rendered as text on the top of the page..
Trackbacks: