3

I want to change the default placeholder text in my Custom Post Type title field. This isn't possible while registering a new post type.

The following screenshot describes it.

Screen from WP Admin

7

I use a code which differs from yours a little bit. There is no need to get the current screen using the enter_title_here-filter because you have already a post-object:

/**
 * Filter: Modifies the standard placeholder text
 * @param string $title
 * @param WP_Post $post
 * @return string
 */
function my_enter_title_here( $title, $post ) {
    if ( 'POST_TYPE' == $post->post_type ) {
        $title = 'Custom placeholder text here';
    }
    return $title;
}
add_filter( 'enter_title_here', 'my_enter_title_here', 10, 2 );
-1
function change_default_title( $title ) {
    $screen = get_current_screen();

    // you can copy/paste the following if statement for other post types
    if( 'POST_TYPE' == $screen->post_type ) {
      $title = 'Custom placeholder text here';
    }

    return $title;
}
add_filter( 'enter_title_here', 'change_default_title' );
  • 4
    Please don't dump code as an answer. As a longstanding member you should know that. Please file an edit and add an explanation to how your code works and how it should be used. Thank you. – Pieter Goosen Nov 5 '14 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.