How to remove “private” and “protected” from the post title

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!
Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to remove…

You Might Also Like...

  • Remove Private/Protected from Post Titles

    1497 readersI had the situation come up where I 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

  • How to automatically remove the Nofollow from your posts

    1542 readersBy default, WordPress automatically converts all links from the post content to nofollow. If you prefer your links to be dofollow, just read and use the following recipe.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to automatically remove the Nofollow from your posts

  • WordPress tip: Insert posts programmatically

    1586 readersDo you know that it is possible to insert post in WordPress programmatically? In this recipe, I'll show you how to do it easily.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress tip: Insert posts programmatically

  • GPL Showdown

    1165 readersIf you missed the Matt Mullenweg vs. Chris Pearson debate live debate today, this is my wrap up: Matt: Thesis is violating the law because it violates GPL. Chris: No it isn’t. Matt: Businesses can thrive under GPL. Chris: So? Matt: Why won’t you bring Thesis over to GPL? Chris: Because I would feel like

  • WordPress tip: allow upload of more file types

    1615 readersFor some reason, WordPress uploader won't let you upload some filetypes, such as Textmate's .tmCommand. If you need to upload those files to your WordPress blog, here is a very nice snippet that will allow you to do it. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try

  • Showing the post password form for excerpts in WordPress

    571 readersHow to replace excerpts for password-protected posts in WordPress with a password form instead of the standard no excerpt message.

  • Remove spaces when echoing the_title

    193 readersEver wanted to print or echo the WordPress title attribute without spaces?

  • Declare Multiple Widgetized Areas

    1850 readersHave a bunch of different areas you wish to declare as a widgetized area? Save repetative code by creating a quick array of their names, then loop through that array calling the register_sidebar() function on each one. Elementary PHP stuff here, but hey, it just saved me quite a few lines of code in a

  • How to create advanced html tables using TableGear

    195 readersTables are a very important part of HTML, but they can also be a pain to deal with. Using TableGear, you can create dynamic tables that can be edited "on the fly" and sort according to your needs. And all that, with almost no effort.Have you checked out the highly recommended Digging into WordPress book

  • WP-Sticky WordPress plugin

    Use WP-Sticky WordPress plugin to easily create feature or “sticky” posts

    638 readersThe WP-Sticky WordPress plugin allows you to easily choose to “stick” certain posts at the top of your blog. This can also be done via code, as I explained in a post a few months ago where I wrote about some code that you can add to your index.php ...