Mika MAtikainen

Apr 15, 2020 · 4 min read

Remove the Private/Protected From Your Post Titles

In case you ever publish posts that are private, you’ll notice that the title is prefaced by an unsightly reminder. You can add the code below to your functions file and everything will look good again.

[code lang=”php”] 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’); [/code]

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This