enter_title_herefilter-hookWP 3.1.0

Allows you to change the placeholder text in the Title field when adding a new post.

Example placeholder when adding a new post

Usage

add_filter( 'enter_title_here', 'wp_kama_enter_title_here_filter', 10, 2 );

/**
 * Function for `enter_title_here` filter-hook.
 * 
 * @param string  $text Placeholder text.
 * @param WP_Post $post Post object.
 *
 * @return string
 */
function wp_kama_enter_title_here_filter( $text, $post ){
	// filter...
	return $text;
}
$text(string)
Placeholder (hint) text.
Default: __( 'Enter title here' )
$post(WP_Post)
Post object. See get_post() for the object structure.

Examples

#1 Change the placeholder text for a custom post type

Suppose an Employees post type with slug = worker has been created (see register_post_type()). Its placeholder can be changed as follows:

add_filter( 'enter_title_here', 'worker_enter_title_here', 10, 2 );
function worker_enter_title_here( $text, $post ) {
	if ( $post->post_type === 'worker' ) {
		$text = 'Enter the employee’s full name';
	}

	return $text;
}

#2 Change the placeholder when adding a post or page

## Change the placeholder when adding a post or page.
add_filter( 'enter_title_here', 'post_enter_title_here', 10, 2 );
function post_enter_title_here( $text, $post ){
	// When adding a post.
	if ( $post->post_type === 'post' ) {
		$text = 'What will your wonderful article be called?';
	}

	// When adding a page.
	if ( $post->post_type === 'page' ) {
		$text = 'Enter a short, clear page title';
	}

	return $text;
}

#3 Change the placeholder when creating a draft through the Dashboard widget

add_filter( 'enter_title_here', 'dashboard_enter_title_here' );
function dashboard_enter_title_here( $text ) {
	if ( get_current_screen()->base === 'dashboard' ) {
		$text = 'Enter the title of the future article';
	}

	return $text;
}

Changelog

Since 3.1.0 Introduced.

Where the hook is called

In file: /wp-admin/edit-form-advanced.php
enter_title_here
wp-admin/edit-form-advanced.php 538
$title_placeholder = apply_filters( 'enter_title_here', __( 'Add title' ), $post );
wp-admin/edit-form-blocks.php 281
'titlePlaceholder'     => apply_filters( 'enter_title_here', __( 'Add title' ), $post ),
wp-admin/includes/dashboard.php 603
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );

Where the hook is used in WordPress

Usage not found.