How can I apply the remove_post_type_support('email_template', 'title');
only for post edit screen?
The title should be available on create and not for edit.
How can I apply the remove_post_type_support('email_template', 'title');
only for post edit screen?
The title should be available on create and not for edit.
In WordPress, there is one global variable to check on which screen we are and it is global $current_screen
but problem is it can not be used with admin_init
action.
So alternatively we can use load-(page) action to achieve it.
add_action( 'load-post.php', 'remove_post_type_edit_screen', 10 );
function remove_post_type_edit_screen() {
global $typenow;
if($typenow && $typenow === 'email_template'){
remove_post_type_support( 'email_template', 'title' );
}
}
You can try it and give it a go.
Let me know if you have any doubt.
Edited
Explanation : If you can notice on the URL bar of the browser, then you can see when you are adding new post then it is calling post-new.php and when you are editing at that time it is calling post.php with parameters.
So we can utilize it to achieve your desired result.
You need to make small function in your function.php
file:
add_action('admin_init', 'email_template_hide_title');
function email_template_hide_title() {
remove_post_type_support('email_template', 'title');
}
I hope, It'll be help.