If you have a blog/site which is more personal and have a lot of private and protected posts, you might have noticed that a prefix is added in the post titles like ,
- Private: Post title
- Protected: Post title
In this article we will find out how to change those formatted post titles or entirely remove those prefixes.
Well how to do this, we use WordPress filters for these.
- protected_title_format
- private_title_format
[php]
function spi_remove_private_protected_from_titles( $format ) {
return ‘%s’;
}
add_filter( ‘protected_title_format’, ‘spi_remove_private_protected_from_titles’ );</pre>
add_filter( ‘private_title_format’, ‘spi_remove_private_protected_from_titles’ );
[/php]
Here we are returning just the post title ( %s ). If you want to show different string like locked for protected posts , you ned to return that string.
[php]
function spi_remove_private_protected_from_titles( $format ) {
return ‘ Locked: %s’;
}
add_filter( ‘protected_title_format’, ‘spi_remove_private_protected_from_titles’ );
[/php]