Site icon SumTips

Change "Enter title here" text for Post, Page and Custom Post Type in WordPress

WordPress 3.1 has added a new filter that allows you to easily change the ‘Enter Title Here’ text that appears in the title input text field.

Example:

With this new filter you can change the default text for post and page editor, and for any specific post type you want.

Change Default Text

To change the default text, add the following code to your functions.php file:
Code:

function custom_title_text( $title ){
$screen = get_current_screen();
$title = 'My Custom Post Type Title Text';
return $title;
}
add_filter( 'enter_title_here', 'custom_title_text' );

This will change the title text everywhere.

Change Default Text in Page Editor

By adding a condition to the previous code you can change the default text of only page editor:

Code:

function custom_title_text( $title ){
$screen = get_current_screen();
if ( 'page' == $screen->post_type ) {
$title = 'My Custom Post Type Title Text';
}
return $title;
}
add_filter( 'enter_title_here', 'custom_title_text' );

Change Default Text for a Custom Post Type

Now, using the same code as above, you can use it for any post type by specifying it’s title and entering desired text.

Code:

function custom_title_text( $title ){
$screen = get_current_screen();
if ( 'page' == $screen->post_type ) {
$title = 'My Custom Post Type Title Text';
}
return $title;
}
add_filter( 'enter_title_here', 'custom_title_text' );
Exit mobile version