Created
November 16, 2022 13:39
-
-
Save endurtech/a8106a8ed755de813c982c63c8f09e02 to your computer and use it in GitHub Desktop.
Remove Protected and Private from titles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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