删除或限制编辑者角色对页面模板的访问 时间:2013-11-27 作者:unwrittendevin 我有一个关于限制博客编辑访问页面模板的问题,他们可能会在将来创建新页面。在我的构建过程中,我必须创建特定的模板来为特定页面添加自定义功能(即,FAQ在单独的循环中从CPT中提取,但允许编辑器使用标准的“页面”帖子类型添加介绍段落)现在,在我移交网站时,我想确保网站编辑器在构建新页面时不会重复使用这些模板。是否有办法按用户角色限制可用的页面模板?或者可以完全删除“页面模板”下拉列表吗?我可以使用Adminimize(http://wordpress.org/plugins/adminimize/) 删除下拉列表,但标签仍然保留。谢谢Devin 2 个回复 SO网友:user37715 下面是一个解决方案metabox 这个解决方案还假设编辑器没有编辑主题的权限。add_action( \'admin_menu\', \'restrict_access\' ); function restrict_access() { if(!current_user_can(\'edit_themes\')){ remove_meta_box( \'pageparentdiv\', \'page\',\'normal\' ); } } 希望这有帮助 SO网友:gmazzap 我想remove_post_type_support 可用于范围:add_action(\'load-post.php\', \'no_page_templates\'); add_action(\'load-post-new.php\', \'no_page_templates\'); function read_only_content() { if ( ! current_user_can(\'manage_options\') ) { // change the cap with the wanted one $scr = get_current_screen(); remove_post_type_support( $scr->post_type, \'page-attributes\' ); } } 结束 文章导航