WordPress Icon Logo
me@grafxflow

Written by me@grafxflow

27 Mar, 2013

2

2,495

Remove the 'Private:' title for private posts

If you are creating private pages or posts for certain members to view, you will notice by default WordPress adds 'Private:' to the title. So the title 'Secret Page/Post' will actually be 'Private: Secret Page/Post'. This is not necessarily what you want the user to see.

So here is the solution:

1. Open the 'functions.php' file that's in your themes folder and add the following code to the end.

function remove_private_prefix($title) {
    $title = str_replace(
    'Private:',
    '',
    $title);
    return $title;
}

add_filter('the_title','remove_private_prefix');

Now the 'Private:' part of the title should no longer appear.

Add comment

2 Response

  1. avatar

    Dawesi

    27 Nov 2016
    `/* Removing private prefix from post titles */


    function spi_remove_private_protected_from_titles( $format ) {
    return '%s';
    }
    add_filter( 'private_title_format', 'spi_remove_private_protected_from_titles' );`
  2. avatar

    me@grafxflow

    27 Nov 2016
    Cheers Dawesi for update.

Smart Search

119 Following
50 Followers

me@grafxflow

Hull, United Kingdom

I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!

Follow