WordPress Function to Remove Private and Protected Prefix

Remove Private and Protected Prefix

This function removes the “Privite:” prefix from posts and pages marked private. Useful for content only visible to logged in users or groups.

function the_title_trim($title) {
$title = attribute_escape($title);
$findthese = array(
$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');

EDIT: Updated to include the removal of Protected: as well.

You may also like...

Leave a Reply

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