Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Alter the WordPress post title placeholder text for posts only.
<?php
/**
* Alter the enter title here placeholder text.
* This is on the WordPress post edit screens.
*
* @param string $title The is the current placeholder string.
* @return string The modified placeholder string.
*/
function hd_title_here( $title, $post ) {
// if this post is not the post type of 'post'.
if ( 'post' !== get_post_type( $post ) ) {
// return the unmodified title placeholder.
return $title'
}
// set a new string for the placeholder text as the post type must be a 'post'.
$title = __( 'Enter article title here.', 'text-domain' );
// return the title back to the hook.
return $title;
}
add_action( 'enter_title_here', 'hd_title_here', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.