Skip to content

Instantly share code, notes, and snippets.

@timothyjensen
Last active June 4, 2019 19:22
Show Gist options
  • Save timothyjensen/29980bb1598215199cccbf51e2b3dd5f to your computer and use it in GitHub Desktop.
Save timothyjensen/29980bb1598215199cccbf51e2b3dd5f to your computer and use it in GitHub Desktop.
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