Title: private_title_format
Published: April 25, 2014
Last modified: May 20, 2026

---

# apply_filters( ‘private_title_format’, string $prepend, WP_Post $post )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#wp--skip-link--target)

Filters the text prepended to the post title of private posts.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#description)󠁿

The filter is only applied on the front end.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#parameters)󠁿

 `$prepend`string

Text displayed before the post title.
 Default ‘Private: %s’.

`$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)

Current post object.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#source)󠁿

    ```php
    $private_title_format = apply_filters( 'private_title_format', $prepend, $post );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/post-template.php#L160)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/post-template.php#L160-L160)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#related)󠁿

| Used by | Description | 
| [get_the_title()](https://developer.wordpress.org/reference/functions/get_the_title/)`wp-includes/post-template.php` |

Retrieves the post title.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 5 content](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#comment-content-4637)
 2.    [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/private_title_format/#comment-4637)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-4637)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-4637)
 4.  Example migrated from Codex:
 5.  Remove protected prefix from post titles.
 6.      ```php
         add_filter( 'private_title_format', 'wpdocs_remove_private_protected_from_titles' );
     
         function wpdocs_remove_private_protected_from_titles( $format ) {
             return '%s';
         }
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%3Freplytocom%3D4637%23feedback-editor-4637)
 8.   [Skip to note 6 content](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#comment-content-5414)
 9.    [henriko](https://profiles.wordpress.org/henriko/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/private_title_format/#comment-5414)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-5414)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-5414)
 11. I got a critical error, when doing as suggested by others, here and elsewhere.
 12. I managed to solve that by doing it like this:
 13.     ```php
         function remove_private_prefix_from_titles( ...$_ ) {
           return "%s";
         }
         add_filter( 'private_title_format', 'wpdocs_remove_private_prefix_from_titles' );
         ```
     
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%3Freplytocom%3D5414%23feedback-editor-5414)
 15.  [Skip to note 7 content](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#comment-content-6338)
 16.   [devtat](https://profiles.wordpress.org/devtat/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/private_title_format/#comment-6338)
 17. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-6338)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-6338)
 18. This filter can be added like this:
 19.     ```php
         add_filter( 'private_title_format', function ($title) {
           return "%s";
         });
         ```
     
 20.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%3Freplytocom%3D6338%23feedback-editor-6338)
 21.  [Skip to note 8 content](https://developer.wordpress.org/reference/hooks/private_title_format/?output_format=md#comment-content-7109)
 22.   [David Brown](https://profiles.wordpress.org/davidhbrown/)  [  2 years ago  ](https://developer.wordpress.org/reference/hooks/private_title_format/#comment-7109)
 23. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-7109)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%23comment-7109)
 24. Tip: Do _not_ use private_title_format() to add formatting using HTML. This will
     break things like the command palette that expect the page title to be plain text
     with no markup. “Format” here means only that you’re returning a sprintf()-style
     format string, not that this is the way to format the appearance of a private 
     title.
 25. (I had added an “unlock” icon using private_title_format(); worked great until
     6.6 added the command palette to the editor which crashed when it tried to display
     a private page’s title. So I moved the formatting into the relevant template .
     php files in the theme.)
 26.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F%3Freplytocom%3D7109%23feedback-editor-7109)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fprivate_title_format%2F)
before being able to contribute a note or feedback.