Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save endurtech/a8106a8ed755de813c982c63c8f09e02 to your computer and use it in GitHub Desktop.
Save endurtech/a8106a8ed755de813c982c63c8f09e02 to your computer and use it in GitHub Desktop.
Remove Protected and Private from titles
<?php
// Remove Protected: and Private: from Titles in WordPress
// https://endurtech.com/remove-protected-private-from-title-in-wordpress/
add_filter( 'the_title', 'the_title_trim' );
function the_title_trim( $title )
{
$title = attribute_escape( $title );
$findthese = array(
'#Protected:#',
'#Private:#'
);
$replacewith = array(
'', // replacement for "Protected:"
'' // replacement for "Private:"
);
$title = preg_replace( $findthese, $replacewith, $title );
return $title;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment