从自定义帖子类型编辑屏幕中删除标题

如何应用remove_post_type_support(’email_template’, ‘title’);仅用于帖子编辑屏幕?

标题应在创建时可用, 不可编辑。


#1


在WordPress中, 有一个全局变量可以检查我们在哪个屏幕上, 它是全局$ current_screen, 但问题是它不能与admin_init操作一起使用。

因此, 我们也可以使用load-(page)动作来实现它。

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' );
    }
}

你可以尝试一下, 然后尝试一下。

如果你有任何疑问, 请告诉我。

已编辑

说明:如果你可以在浏览器的URL栏上看到, 则可以看到何时添加新帖子, 然后调用post-new.php, 当你进行编辑时, 它调用带参数的post.php。

因此, 我们可以利用它来达到你想要的结果。


#2


你需要在function.php文件中制作小功能:

add_action('admin_init', 'email_template_hide_title');
function email_template_hide_title() {
     remove_post_type_support('email_template', 'title');
}

希望会有所帮助。

来源:

https://www.srcmini02.com/67450.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_36886.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?