这可以通过一些简单的JavaScript/jQuery来完成.创建一个名为admin_title_disable.js的文件,并在functions.php中对其进行排队.例如:
的functions.php:
wp_register_script('admin_title_disable', '/path/to/admin_title_disable.js');
function disableAdminTitle () {
wp_enqueue_script('admin_title_disable');
}
add_action('admin_enqueue_scripts', 'disableAdminTitle');
Run Code Online (Sandbox Code Playgroud)
现在,在你的js文件中:
jQuery(document).ready(function ($) {
$('#title').attr('disabled','disabled');
});
Run Code Online (Sandbox Code Playgroud)
这将使用disabled属性设置帖子和页面标题输入字段.希望这可以帮助!
如果要将此脚本限制为特定管理页面,请将add_action钩子包装在比较条件中$_GET['page'].您还$hook可以利用admin_enqueue_scripts用于检查页面时可用的参数.看到这里.
更新::
WordPress使得在帖子和页面编辑屏幕之间分配有点棘手,但是有一个隐藏的输入可以利用.:)这是jQuery的更新版本,只能在页面编辑屏幕上运行:
jQuery(document).ready(function ($) {
//find the hidden post type input, and grab the value
if($('#post_type').val() === 'page'){
$('#title').attr('disabled','disabled');
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2580 次 |
| 最近记录: |