protected_title_format

Filters the text prepended to the post title for protected posts.

Description

apply_filters( 'protected_title_format', (string) $var, (WP_Post) $post ); 

The filter is only applied on the front end.

Parameters (2)

0. $var (string) => __( 'Protected: %s' )
Text displayed before the post title. Default Protected: %s..
1. $post (WP_Post)
Current post object.

Usage

To run the hook, copy the example below.
  1. $var = apply_filters( 'protected_title_format', $var, $post ); 
  2.  
  3. if ( !empty( $var ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the protected_title_format callback 
  2. function filter_protected_title_format( $var, $post ) { 
  3. // make filter magic happen here... 
  4. return $var
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'protected_title_format', 'filter_protected_title_format', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'protected_title_format', 'filter_protected_title_format', 10, 2 ); 

Defined (3)

The filter is defined in the following location(s).

/wp-includes/post-template.php  
  1. $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ), $post ); 
/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php  
  1. add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 
  1. remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );