The enter_title_here WordPress PHP filter allows you to modify the default placeholder text of the title field in the WordPress editor.
Usage
add_filter('enter_title_here', 'custom_title_placeholder', 10, 2); function custom_title_placeholder($text, $post) { // your custom code here return $text; }
Output: Modified title field placeholder text.
Parameters
- $text (string): Placeholder text. Default ‘Add title’.
- $post (WP_Post): Post object.
More information
See WordPress Developer Resources: enter_title_here
Examples
Custom title placeholder for ‘page’ post type
Change the title placeholder for pages.
add_filter('enter_title_here', 'custom_page_title_placeholder', 10, 2); function custom_page_title_placeholder($text, $post) { if ('page' == $post->post_type) { $text = 'Enter page title'; } return $text; }
Output: “Enter page title” for pages.
Custom title placeholder for a custom post type
Change the title placeholder for a custom post type ‘recipes’.
add_filter('enter_title_here', 'custom_recipe_title_placeholder', 10, 2); function custom_recipe_title_placeholder($text, $post) { if ('recipes' == $post->post_type) { $text = 'Enter recipe name'; } return $text; }
Output: “Enter recipe name” for recipes.
Different placeholders for multiple post types
Customize title placeholders for multiple post types.
add_filter('enter_title_here', 'custom_multiple_post_type_title_placeholder', 10, 2); function custom_multiple_post_type_title_placeholder($text, $post) { if ('post' == $post->post_type) { $text = 'Enter blog post title'; } elseif ('products' == $post->post_type) { $text = 'Enter product name'; } return $text; }
Output: “Enter blog post title” for posts, “Enter product name” for products.
Title placeholder based on post format
Change the title placeholder based on the post format.
add_filter('enter_title_here', 'custom_post_format_title_placeholder', 10, 2); function custom_post_format_title_placeholder($text, $post) { $post_format = get_post_format($post->ID); if ('video' == $post_format) { $text = 'Enter video post title'; } elseif ('gallery' == $post_format) { $text = 'Enter gallery post title'; } return $text; }
Output: “Enter video post title” for video posts, “Enter gallery post title” for gallery posts.
Title placeholder for specific category
Change the title placeholder for posts in the ‘News’ category.
add_filter('enter_title_here', 'custom_news_category_title_placeholder', 10, 2); function custom_news_category_title_placeholder($text, $post) { $news_category = get_category_by_slug('news'); if (has_category($news_category->term_id, $post)) { $text = 'Enter news article title'; } return $text; }
Output: “Enter news article title” for posts in the ‘News’ category.