Jon Cave has written an excellent guide to the WordPress rewrite endpoints API, useful for adding new suffixes to things like post permalinks. If you’re a WordPress developer, it’s well worth the read.
Tag Archives: guide
How To Remove (Or Change) “Private” Or “Protected” From WordPress Post Titles
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.