How to change “Enter Title Here” text for custom post type

Here’s another tiny WordPress code snippet which allows you to change “Enter title here” placeholder text in post title input field on the add new post screen. This can be very helpful while dealing with custom post types.

How to change “Enter Title Here” text for custom post type

How to change “Enter Title Here” text for custom post type

Let’s say you have a custom post type called “News” and want to change the placeholder text “Enter title here” to “Enter the headline”, this can be easily done by adding a small amount of code to your functions.php file.

To change the “Enter title here” text, paste the following code to your functions.php file.

function change_default_title( $title ){
     $screen = get_current_screen();
 
     if  ( 'news' == $screen->post_type ) {
          $title = 'Enter the Headline';
     }
 
     return $title;
}
 
add_filter( 'enter_title_here', 'change_default_title' )

To change the placeholder for default ‘Posts’ use the following code snippet,

function title_text( $title ){
     return $title = 'Your custom placeholder';
}
add_filter( 'enter_title_here', 'title_text' );

Useful Read: How to change howdy text in WordPress?

0 Comments

Leave a Comment.