Change Default “Enter Title Here” Placeholder Text In Post Screen

How to Change Default “Enter Title Here” Placeholder Text In Post Screen

in WordPress Admin
Google+ LinkedIn

By default WordPress displays “Enter title here” placeholder text in the post title field section on the post screen, where you create a new post. But in case of custom post type, while we register our custom post type, there is no parameter or option to change this default placeholder text to provide more personalized touch to our post type titles section. For example if you register a custom post type for books then wouldn’t’ it be nice to have “Enter book name” placeholder text instead of default “Enter title here“. So in this topic I will show you how you can replace default placeholder text with the text you want to use.

Fortunately WordPress provide an easy way to change title placeholder text. WordPress has a filter named enter_title_here which allows us to change “Enter title here” text in WordPress posts screen and custom post types’ screen. So following code snippet will change “Enter title here” placeholder text to “Enter book name” for Book post types. Just drop the following snippet to your current theme’s functions.php file.

// change "Enter title here" placeholder text
function wpcs_change_title_placeholder_text( $title ) {
    $screen = get_current_screen();
    if  ( 'book' == $screen->post_type ) {
        $title = 'Enter book name';
    }
    return $title;
}
add_filter( 'enter_title_here', 'wpcs_change_title_placeholder_text' );

That’s all!

Share the love

If you like this snippet, share it with others!

Leave a Reply

Your email address will not be published. Required fields are marked *