Written by me@grafxflow
27 Mar, 2013
2
2,818
If you are creating private pages or posts for certain members to view, you will notice by default WordPress adds 'Private:' to the title. So the title 'Secret Page/Post' will actually be 'Private: Secret Page/Post'. This is not necessarily what you want the user to see.
So here is the solution:
1. Open the 'functions.php' file that's in your themes folder and add the following code to the end.
function remove_private_prefix($title) {
$title = str_replace(
'Private:',
'',
$title);
return $title;
}
add_filter('the_title','remove_private_prefix');
Now the 'Private:' part of the title should no longer appear.
11 Nov, 2018
30 Apr, 2017
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow11 Jul, 2023
21 Jun, 2023
Views: 166,337
Views: 40,317
Views: 37,063
Views: 33,610
2 Response
Dawesi
27 Nov 2016
`/* Removing private prefix from post titles */
function spi_remove_private_protected_from_titles( $format ) {
return '%s';
}
add_filter( 'private_title_format', 'spi_remove_private_protected_from_titles' );`
me@grafxflow
27 Nov 2016
Cheers Dawesi for update.