上面的答案對我不起作用,但是做什麼工作更復雜。我在http://wordpress.stackexchange.com/questions/228770/remove-nav-menus-from-customizer-using-a-theme找到了答案,但這裏又是一次。將以下內容添加到主題的functions.php文件中。
add_action('customize_register', function ($WP_Customize_Manager){
//check if WP_Customize_Nav_Menus object exist
if (isset($WP_Customize_Manager->nav_menus) && is_object($WP_Customize_Manager->nav_menus)) {
//Remove all the filters/actions resiterd in WP_Customize_Nav_Menus __construct
remove_filter('customize_refresh_nonces', array($WP_Customize_Manager->nav_menus, 'filter_nonces'));
remove_action('wp_ajax_load-available-menu-items-customizer', array($WP_Customize_Manager->nav_menus, 'ajax_load_available_items'));
remove_action('wp_ajax_search-available-menu-items-customizer', array($WP_Customize_Manager->nav_menus, 'ajax_search_available_items'));
remove_action('customize_controls_enqueue_scripts', array($WP_Customize_Manager->nav_menus, 'enqueue_scripts'));
remove_action('customize_register', array($WP_Customize_Manager->nav_menus, 'customize_register'), 11);
remove_filter('customize_dynamic_setting_args', array($WP_Customize_Manager->nav_menus, 'filter_dynamic_setting_args'), 10, 2);
remove_filter('customize_dynamic_setting_class', array($WP_Customize_Manager->nav_menus, 'filter_dynamic_setting_class'), 10, 3);
remove_action('customize_controls_print_footer_scripts', array($WP_Customize_Manager->nav_menus, 'print_templates'));
remove_action('customize_controls_print_footer_scripts', array($WP_Customize_Manager->nav_menus, 'available_items_template'));
remove_action('customize_preview_init', array($WP_Customize_Manager->nav_menus, 'customize_preview_init'));
remove_filter('customize_dynamic_partial_args', array($WP_Customize_Manager->nav_menus, 'customize_dynamic_partial_args'), 10, 2);
}
}, -1); //Give it a lowest priority so we can remove it on right time
來源
2017-11-22 05:30:11
Ted
你的主題是否有'customizer.php'? – 2016-12-26 00:49:09