Change the “Enter Title Here” placeholder text for custom posts

Not every change in WordPress should be about installing a new feature or changing important parts of system’s functionality. Sometimes it is as important to take care of the small things and create a user-friendly experience for your clients.

When it comes to titles, you can do those small changes which, combined, can create a bigger impact on the theme you’re working on. We already showed you how to limit the number of characters in titles and how to align that title differently. That’s the kind of small changes we’re talking about.

In today’s article, we are about to show you something similar. We’re sure that you are already aware of “Enter Title Here” text which appears as a placeholder in both of your posts editors for every post type you’re working with. While there is no reason just to translate the text because you can easily have the entire WordPress in your own language, sometimes it would be nice to slightly modify the text to your needs.

Enter title here placeholder

Maybe you want to show some funny text instead the regular one, or maybe you are working with a custom post type which is designed specifically for movies, music, books or anything else. In that case, you could create “Enter Movie Name”, “Song Name” or “Book Name” placeholder instead of the standard one.

Change the title placeholder:

Luckily, WordPress developers were kind enough to think about those small changes as well. They have already prepared a filter which we can easily modify and change the placeholder in a matter of seconds:

  1. Open functions.php file
  2. Copy and paste the following WP code:
  3. function title_placeholder( $title ) {
    $screen = get_current_screen();
    if  ( 'movie' == $screen->post_type ) {
    $title = 'Movie Name';
    }
    return $title;
    }
    add_filter( 'enter_title_here', 'title_placeholder' );
    
  4. Change custom post name and placeholder text on line 3 and 4
  5. Save changes

As you can see, the code is fairly simple so it won’t be hard to modify it. All you have to do in order to change you placeholder text is to change 3rd and 4th line to anything you want. If you have basic PHP skills, you can easily expand the code and create the entire array of custom posts and change the title placeholder accordingly.

In the end, the change really isn’t something that big and important, but once your authors start to work on the site and start writing new titles on a daily basis, a change here and a change there will mean something in the long run. You want your authors to be satisfied with the site they’re working on, don’t you?

Since you’re still working on titles, you might want to change the title separator or maybe even create a list of words which won’t be allowed in titles.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

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