Dukeo » WordPress » Remove “Private” & “Protected”: How To Do This in WordPress

Remove “Private” & “Protected”: How To Do This in WordPress

Steven WordPress

Whenever you publish a post and set it to being Private or Password-Protected, WordPress will automatically prepend “Private:” or “Protected:” to your WordPress blog post title.

However, if you want to keep your post titles clean, all you need to do is paste the following piece of code in your functions.php file:

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');

Once the code is pasted in fuctions.php, simply save the file and it will be activated automatically.

If you enjoyed this article,
Get email updates

Join for Free »