Change the Protected: Label in WordPress

In WordPress, when you password-protect a page or post, the default label “Protected:” appears before the title of the protected content. While this default label works fine, you might want to customize it to better fit your site’s tone or branding. In this post, we’ll explore two methods for changing this label: using a WordPress hook/filter or through the Loco Translate plugin.

Method 1: Changing the Label Using a WordPress Hook/Filter

WordPress provides a flexible way to modify various aspects of your site using hooks and filters. To change the “Protected:” label, you can use the protected_title_format filter. Here’s how you can do it:

Add the Code to Your Theme’s functions.php File:

You can add the following code snippet to your theme’s functions.php file or a custom functionality plugin:

function custom_protected_title_format($title) {
    // Replace 'Custom Label:' with your desired label
    $new_label = 'Your Custom Label:';
    return str_replace('Protected:', $new_label, $title);
}
add_filter('protected_title_format', 'custom_protected_title_format');

In this code:

  • custom_protected_title_format is a custom function that replaces the default “Protected:” label with your specified label.
  • add_filter(‘protected_title_format’, ‘custom_protected_title_format’); hooks our function to the protected_title_format filter, which modifies the title format of protected posts/pages.

Save Changes:

After adding the code, save the functions.php file. The new label should now appear in place of “Protected:” on all password-protected posts and pages.

Method 2: Changing the Label Using the Loco Translate Plugin

If you prefer a more user-friendly method without coding, you can use the Loco Translate plugin to translate the “Protected:” label directly in WordPress.

Install and Activate the Loco Translate Plugin:

  • Go to the WordPress Dashboard.
  • Navigate to Plugins > Add New.
  • Search for Loco Translate and install the plugin.
  • Activate the plugin once installed.

Translate the String:

  • Go to Loco Translate > Plugins.
  • Select WordPress from the list of plugins.
  • Click on the English (or the language you are using) to open the translation editor.
  • Search for the string “Protected:” in the search box.
  • Edit the translation by replacing “Protected:” with your desired text.
  • Save your changes.

Verify the Change:

Visit a password-protected page or post on your site to ensure that the label has been updated.

Conclusion

Customizing the “Protected:” label for password-protected pages and posts in WordPress can be done easily using either of the methods described. Whether you choose to edit code directly or use the Loco Translate plugin, both approaches allow you to tailor your site’s appearance to better match your brand.

Feel free to implement the method that best suits your needs and enjoy a more personalized WordPress experience!

Leave A Comment

Hire For Avada Customization

Fed up with disappointing experiences from so-called Avada experts? Give me a chance, and you'll find a reliable Avada pro you'll never want to replace!

2024's
Best WordPress Managed Hosting
4 Months Free on Annual Plan

Its the Real Deal