我在寻找一种隐藏父主题模板的方法,并找到了这个答案,它可以完美地从页面编辑屏幕中删除父模板-How to *remove* a parent theme page template from a child theme?.
我不希望删除的父模板显示在admin中的任何位置,但是它们仍然显示在“快速编辑”部分中WP admin>Pages>All Pages上标记为“Template”的下拉框中。有人知道这样做的方法吗?
我在寻找一种隐藏父主题模板的方法,并找到了这个答案,它可以完美地从页面编辑屏幕中删除父模板-How to *remove* a parent theme page template from a child theme?.
我不希望删除的父模板显示在admin中的任何位置,但是它们仍然显示在“快速编辑”部分中WP admin>Pages>All Pages上标记为“Template”的下拉框中。有人知道这样做的方法吗?
答案重新制作。原来是个疯狂的想法。。。
答案与Rarst在链接问题中发布的答案相同
How to *remove* a parent theme page template from a child theme?
区别在于admin_head
挂钩
和一项仅用于磨合的检查edit-page
而且不在edit-post
或edit-custom_post_type
, 因为所有这些案件都是由admin_head-edit.php
.
父母是“二十一”,孩子叫“十二”。
add_action(\'admin_head-edit.php\',\'wpse_54054_remove_template\');
function wpse_54054_remove_template()
{
global $wp_themes,$current_screen;
if(\'edit-page\' != $current_screen->id)
return;
get_themes();
$templates = &$wp_themes[\'Twenty Twelve\'][\'Template Files\'];
$template1 = trailingslashit( TEMPLATEPATH ).\'showcase.php\';
$template2 = trailingslashit( TEMPLATEPATH ).\'sidebar-page.php\';
$key1 = array_search($template1, $templates);
$key2 = array_search($template2, $templates);
unset( $templates[$key1], $templates[$key2] );
}