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.
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.