Paulund
2014-02-10 #wordpress

Remove Protected From Post Titles

In WordPress you can easily password protect a page from the admin area. All you have to do is under the publish block edit visibility and select password protected. A textbox will appear and you can type in a password for the page. The password is not a password field so it's not hidden from view, this is so admin users can still see what the password for the page is. The next time you visit the page you will be asked to type in a password to see this page.

Once the correct password is entered you will be redirected back to the content of the page. If you use the function the_title() in your theme will automatically add a Protected: before the title. If you want to remove this Protected: from the title of the page you need to add a new filter to protected_title_format. Below is a code snippet that will remove the Protected:, the return of this function is used for the format of the sprintf() function to display the title. Therefore if you just want to display the title you just have to return %s, if you want to change the text to This page is protected then you can return 'This page is protected %s'.


function removed_protected_format( $title )
{
    return '%s';
}
add_filter('protected_title_format', 'removed_protected_format');