Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Change Private and Protected Posts Prefix in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Change Private and Protected Posts Prefix in WordPress

Do you find yourself having a lot of private or protected posts? If you do, then you probably notice that WordPress puts either Private: or Protected: in front of the title. Most users could careless about what goes in front, if they are the only one seeing the site. But, if you have a multi-author blog, or a personal blog, you can make things interesting by changing the default prefix.

For example: if you have a personal blog which your family reads, then you can have all protected posts title say: “Family Only: Post Title Goes Here”.

In this article, we will show you how easy it is to change the private and protected posts prefix in WordPress.

Change Protected Posts Prefix

Simply paste the following code in your theme’s functions.php file

function change_protected_title_prefix() {
    return 'Family Only: %s';
}
add_filter('protected_title_format', 'change_protected_title_prefix');

Change Private Post Prefix

Paste the following code in your theme’s functions.php file:

function change_private_title_prefix() {
    return 'Editors Only: %s';
}
add_filter('private_title_format', 'change_private_title_prefix');

You don’t have to use the examples we suggested. You can get creative with this. This is just another way you can spice up your blog.

This article is presented to you by the leader in fast postcard printing, Next Day Flyers.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Natalie says:

    Hi,
    I copied & pasted the “protected” post prefix code and got an error.
    Is the syntax of this code 100% correct?
    Thanks!

  2. bfred_it says:

    Is there a similar hook to change the title format of normal pages and posts? I couldn’t find any!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.