How to hook into the CPT’s title placeholder?

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 );

Leave a Comment