If you make a post private in WordPress, the post’s title with be prefixed with “Private”. The same will happen if you password protect the post, although it will be prefixed with “Protected”. If you’d like to remove these, just add the following code to your theme’s functions.php
file:
add_filter( 'private_title_format', 'yourprefix_private_title_format' ); add_filter( 'protected_title_format', 'yourprefix_private_title_format' ); function yourprefix_private_title_format( $format ) { return '%s'; }
The above code will remove the prefix by changing the format from Private: %s
and Protected: %s
to just %s
where %s
is the existing post title.
If you’d like to change it to something else, you can just change what the function in my example returns. If you want to change them independently of each other, then you’ll need to use two separate callback functions.
Great tip, but I am afraid something is missing from the code… I encounter a 500 server error as soon as I add this to my functions.php file
Oops, my bad. There were spaces in fromt of the return call instead of a tab.
Odd, that shouldn’t matter.
Very nice trick.
Thank you very much
Nicolas
hey alex,
I was wondering if you could help. how would I add this filter which works great by the way, to theme child functions.php? I’m getting errors when I try to use functions.php from the child theme dir.
thanks in advance
paul
What kind of errors? It should work perfectly fine.
Very Good Code! Thanks you! Helped me alot!
Very nice. Thank you.
Many thanks for this !!
Thanks for the tip! Works perfect
Thanks! Big help! But I also would like to change the text “private” on the adminpages to f.e. “locked”? Any ideas?
The “locked” text shows up when someone else is editing the post right now. It is unrelated to this functionality.
You may find this post more useful: http://www.viper007bond.com/2011/07/13/changing-core-wordpress-strings/
The code in your other post is even better!!! Now I can change other texts too to make WordPress a more businesslike CMS for my authors.(I don’t want them to be greeted with ‘howdy’). Million thanks Alex!
THANK YOU !
Great code, the only one which has been working for me (and I’ve tried several)
thanks!!!!!!! simple and effective !
Thank you ! Old post but still relevant 🙂
Pingback: WordPress: Private / Protected nicht anzeigen – datentraeger