[resolved] How to remove "Protected" from pw protected page titles (7 posts)

  1. syncbox
    Posted 6 years ago #

    When you password protect a page in 2.8.5 and the user enters the password, the title changes to prepend "Protected:" to the actual title.

    How do you stop that behavior? Help appreciated!

  2. syncbox
    Posted 6 years ago #

    Nevermind, found my own answer (again).

    It's in the "get_the_title() functions in the post-template.php file in wp-includes, line 113 in version 2.8.5

    $protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));

  3. bluepixeldesign
    Posted 6 years ago #

    But doesn't it get reset every time you update WordPress?

    I saw a fix for something else where you added code to the functions.php file in your theme so this doesn't happen. Anyone know what that code might be?

  4. bluepixeldesign
    Posted 6 years ago #

  5. jbcal
    Posted 5 years ago #

    Hi. The information on wprecipes.com states:

    The only thing you have to do is to paste the following piece of code in your functions.php file. Once you'll save the file, the hack will be applied to your your posts.

    function the_title_trim($title) {
    	$title = attribute_escape($title);
    	$findthese = array(
    	$replacewith = array(
    		'', // What to replace "Protected:" with
    		'' // What to replace "Private:" with
    	$title = preg_replace($findthese, $replacewith, $title);
    	return $title;
    add_filter('the_title', 'the_title_trim');

    I am not understanding where to put the add_filter('the_title', 'the_title_trim');

    Copying and pasting throws an error on my site, but when I remove that last line, the error is not thrown, but the "Protected" is still visible, so it obviously needs to be included.

    Any insight on this is greatly appreciated.


  6. pixeloco
    Posted 5 years ago #

    I posted the above code at the very top of my functions.php file and it successfully removed "Protected:" from my post titles... but I got a bunch of errors in my backend (in the post/page editors and whatnot). Placing the code elsewhere in my functions file just gave me an error and wouldn't load my site.

    Solution that worked for me:

    add_filter('protected_title_format', 'blank');
    function blank($title) {
           return '%s';

    Copy and paste that code snippet at the top of your functions file... (after <?php )

    Hope that helps!

  7. jbcal
    Posted 5 years ago #

    Thanks stacybird! That did it.

Topic Closed

This topic has been closed to new replies.

About this Topic