Change ‘Enter Title Here’ Text for custom wordpress post

Change ‘Enter Title Here’ Text for custom wordpress post

WordPress has functionality of create custom post type. By default wordpress shows “Enter Title Here” for every post type. Basically every content type is custom post in wordpress. When you create new post you will able to see this placeholder text.

For custom post type we need to add  Change ‘Enter Title Here’ Text for custom wordpress post. Many times we create custom post type for custom projects. Here in this article we shown you, how to create custom post type and change placeholder text.

When we want to customize custom post

If we are creating product custom type and want to add product description and their photos. For that you cannot use ‘Enter Title Here’ text. You need to give information to admin users with clear directions. So many times with custom post type you need to change placeholder text.

Using Following code You can create custom Post type

You need open functions.php file from your theme files and put following code.


add_action( 'init', 'create_product_init' );
/**
* Register a product post type.
*
* @link https://purabtech.in/create-wordpress-custom-post-type-permalink-structure/
*/
function create_product_init() {
$labels = array(
'name'               =>'Products',
'add_new_item'       => __( 'Add New product', 'your-plugin-textdomain' ),
'new_item'           => __( 'New product', 'your-plugin-textdomain' ),
'edit_item'          => __( 'Edit product', 'your-plugin-textdomain' ),
'view_item'          => __( 'View product', 'your-plugin-textdomain' )

);

$args = array(
'labels'             => $labels,
'public'             => true,
'publicly_queryable' => true,
'show_ui'            => true,
'show_in_menu'       => true,
'query_var'          => true,
'rewrite'            => array( 'slug' => 'product' ),
'capability_type'    => 'post',
'has_archive'        => true,
'hierarchical'       => false,
'menu_position'      => null,
'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);

register_post_type( 'product', $args );
}

 

Using above code you can create Product custom post.

Now Change ‘Enter Title Here’ Text for custom wordpress post

Use following code in functions.php file.


add_filter( 'enter_title_here', 'custom_product_enter_title' );

function custom_product_enter_title( $input ) {
global $post_type;

if ( is_admin() && $post_type == 'product')
return __( 'Enter Product Name here', 'your_textdomain' );

return $input;
}

 

Change ‘Enter Title Here’ Text for custom wordpress post
Change ‘Enter Title Here’ Text for custom wordpress post

 

Changed Placeholder text will look like as above shown in image. It is very simple and short code. You can change above code as per your project requirement.

For displaying custom post type on wordpress page you can check this article. If you want to upload file with meta box in wordpress with custom post type than check this article. There are many wordpress tutorial we written about wordpress custom post type.

 

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.