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' );
6 thoughts on “Change "Enter title here" text for Post, Page and Custom Post Type in WordPress”
Hello,
I think I am missing something here .. I have played around with this and cannot seem to make this work at all. I am setting it up as a simple plugin and pasting the code above and nothing seems to work.. I have tried all post / page types options you listed above and still nothing… ??
Any suggestions?
Thank you!
LOL… sorry.. I was not using 3.1 – my wp install is 3.4
WP 3.4 is out already? Where have I been?
Thanks for the tip! Very useful. I was thinking if there is something similar, but for the text area? Put inside the text area something like “how to post..”. Any tip? Thank!
Hi,
I have used this code, it works perfectly for one custom post type but when I tried duplicating it for multiple post types it goes very wrong.
Any suggestions?
Thanks in advance.
Solved it… I was being a wee bit stupid and duplicating the function