Remove “Private:” From WordPress Titles

I needed to be able filter out the text "Private:" for posts and pages that were password protected but did not want to edit any core WordPress files. To filter out that text, I added the following code into my functions.php file (within my theme directory):

PHP:
  1. function remove_private_prefix($title) {
  2. $title = str_replace(
  3. 'Private:',
  4. '',
  5. $title);
  6. return $title;
  7. }
  8. add_filter('the_title','remove_private_prefix');

(I also posted this filter in the WordPress Support Forum)