Filter hook 'protected_title_format'

in WP Core File wp-includes/post-template.php at line 141

View Source

protected_title_format

Filter Hook
Description
Filters the text prepended to the post title for protected posts. The filter is only applied on the front end.

Hook Information

File Location wp-includes/post-template.php View on GitHub
Hook Type Filter
Line Number 141

Hook Parameters

Type Name Description
string $prepend Text displayed before the post title. Default 'Protected: %s'.
WP_Post $post Current post object.

Usage Examples

Basic Usage
<?php
// Hook into protected_title_format
add_filter('protected_title_format', 'my_custom_filter', 10, 2);

function my_custom_filter($prepend, $post) {
    // Your custom filtering logic here
    return $prepend;
}

Source Code Context

wp-includes/post-template.php:141 - How this hook is used in WordPress core
<?php
 136  			 *
 137  			 * @param string  $prepend Text displayed before the post title.
 138  			 *                         Default 'Protected: %s'.
 139  			 * @param WP_Post $post    Current post object.
 140  			 */
 141  			$protected_title_format = apply_filters( 'protected_title_format', $prepend, $post );
 142  
 143  			$post_title = sprintf( $protected_title_format, $post_title );
 144  		} elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) {
 145  
 146  			/* translators: %s: Private post title. */

PHP Documentation

<?php
/**
			 * Filters the text prepended to the post title for protected posts.
			 *
			 * The filter is only applied on the front end.
			 *
			 * @since 2.8.0
			 *
			 * @param string  $prepend Text displayed before the post title.
			 *                         Default 'Protected: %s'.
			 * @param WP_Post $post    Current post object.
			 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/post-template.php
Related Hooks

Related hooks will be displayed here in future updates.