Customized “Protected” Text for Password Protected Content

When content is set to Password Protected, the word “Protected” appears in front of the title in the content area within loops, and on single Post and Pages.

You can edit this default text using this function (place in functions.php):

/* Removes or edits the 'Protected:' part from posts titles */
 
add_filter( 'protected_title_format', 'remove_protected_text' );
function remove_protected_text() {
return __('Protected: %s'); // where the magic happens
}

You can update the text to something else:

add_filter( 'protected_title_format', 'remove_protected_text' );
function remove_protected_text() {
return __('Early Access: %s'); // where the magic happens
}

Or remove the text completely:

add_filter( 'protected_title_format', 'remove_protected_text' );
function remove_protected_text() {
return __('%s'); // where the magic happens
}

Source.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.