How To Edit Private/Protected Posts Title Prefix In WordPress

In past last article, I showed how you can remove the private/protected prefix from posts. I was wondering what if you’re using private or password protected posts to run a membership or company website?

We can also edit private/protected posts title prefix in WordPress to a custom text, so we could use these visibility options in our own way and niche.

Change Protected Posts Prefix

Just add following code to your current theme’s functions.php file:

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

Change Private Post Prefix

Just add following code to your current theme’s functions.php file:

function change_private_title_prefix() {
    return 'Attention Writers: %s';
}
add_filter('private_title_format', 'change_private_title_prefix');

Leave a Reply

Your email address will not be published. Required fields are marked *