How to Replace ‘Enter Title Here’ Text in WordPress

WordPress displays ‘Enter title here’ placeholder text in the title field when you create a new post. Recently one of our users asked if they can replace it with their own placeholder text. This is particularly useful when you are using custom post types or creating a custom CMS for clients. In this article, we will show you how to replace ‘Enter title here’ text in WordPress.

When and Why You Need to Replace Title Placeholder Text?

Let’s say you have created a custom post type to create personal profiles, and you want the person’s name to be used as the title. By replacing the placeholder text, you can instruct users to use this field to enter the name.

You can create any type of content, and there is no reason why you should be using a generic text when you can make it more helpful for users.

Replacing The Title Placeholder Text in WordPress

All you need to do is add this code in your theme’s functions.php file or a site-specific plugin.

function wpb_change_title_text( $title ){
     $screen = get_current_screen();
  
     if  ( ‘movie’ == $screen->post_type ) {
          $title = ‘Enter movie name with release year’;
     }
  
     return $title;
}
  
add_filter( ‘enter_title_here’, ‘wpb_change_title_text’ );

Don’t forget to replace ‘movies’ with your own custom post type, and the text with your own custom text.

Let us explain the code. First we created a function wpb_change_title_text. Inside the function, we added a check to see if the user is on a particular custom post type screen.

When it detects that a user is on that particular custom post type screen, then it should return our custom title text. After that we simply hooked our function to the enter_title_here filter which allows you to change the default title text.

That’s all, you can now create a new entry in your custom post type and you will see your own custom placeholder text in the title field.

We hope this article helped you replace ‘Enter title here’ text in WordPress post editor. You may also want to check out our guide on how to add default content in WordPress post editor.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.

Source: Paulund

Leave a Reply

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

error: Content is protected !!

Pin It on Pinterest

Add address