Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change the placeholder text for the post title field.
<?php
// Add 'title_placeholder' to the array of arguments when registering the custom post type.
$cpt_args = array(
'title_placeholder' => 'Team member name',
);
register_post_type( 'team_members', $cpt_args );
<?php
add_filter( 'enter_title_here', 'prefix_change_title_placeholder_text' );
/**
* Change the placeholder text for the post title field.
*
* @param string $title Default placeholder text.
* @return string
*/
function prefix_title_placeholder_text( $title ) {
$post_type_object = get_post_type_object( get_post_type() );
if ( empty( $post_type_object->title_placeholder ) ) {
return $title;
}
return $post_type_object->title_placeholder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment