問題描述
我的主題不使用標籤行,我該如何從自定義程式中刪除?
最佳解決方案
晚會到晚會,但這樣做的訣竅在於:
$wp_customize->remove_control('blogdescription');
你想刪除只是那個控制元件,而不是整個部分,如上所述。
次佳解決方案
使用此程式碼在 wordpress 主題中刪除預先定製的設定。
add_action( "customize_register", "ruth_sherman_theme_customize_register" );
function ruth_sherman_theme_customize_register( $wp_customize ) {
//=============================================================
// Remove header image and widgets option from theme customizer
//=============================================================
$wp_customize->remove_control("header_image");
$wp_customize->remove_panel("widgets");
//=============================================================
// Remove Colors, Background image, and Static front page
// option from theme customizer
//=============================================================
$wp_customize->remove_section("colors");
$wp_customize->remove_section("background_image");
$wp_customize->remove_section("static_front_page");
}
第三種解決方案
我發現 WP_Customize_Manager 類有一個名為 remove_section()的函式。在你的功能掛鉤到 customize_register 你可以做:
$wp_customize->remove_section('nav');
$wp_customize->remove_section('static_front_page');
如果您檢查該部分的手風琴標題欄,您可以找到該部分的 ID(即’nav’) 。看看含有<li> 標籤的 ID,它是"customize-section-"之後的字串部分。即:
<li id="customize-section-static_front_page" class="control-section customize-section">
– ID 為"static_front_page"
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。
