問題描述
我有一個網站有一些額外的 Customizer 部分。有沒有辦法直接鏈接到這些頁面,以便頁面加載時打開?
像 http://mysites.com/wp-admin/customize.php#fonts
screenshot http://new.tinygrab.com/96412a96d208cf8ff0cf5803327b2d29e0ca68810e.png
最佳解決方案
如您已經發現的,定製程序的鏈接始終以/wp-admin/customize.php 開頭。
附加?autofocus[ section ] = section_name 以在定製程序中檢出您的部分。兩個參數 (section 和 section_name) 均已註冊到您的 customize_register 鈎子中:
$wp_customize->add_section
如果找不到掛鈎,請查看定製器的 HTML 標記以獲取更多信息。這兩個參數都包含在列表中:
<li id="accordion-section-title_tagline" class="accordion-section control-section control-section-default">
總而言之,您的鏈接可能如下所示:
admin_url( '/customize.php?autofocus[section]=section_name' );
這些是 Twenty Sixteen WordPress 主題中默認定製程序部分的鏈接:
-
站點標識:
/customize.php?autofocus[section]=title_tagline -
顏色:
/customize.php?autofocus[section]=colors -
標題圖片:
/customize.php?autofocus[section]=header_image -
背景圖片:
/customize.php?autofocus[section]=background_image -
菜單:
/customize.php?autofocus[panel]=nav_menus -
小工具:
/customize.php?autofocus[panel]=widgets -
靜態前頁:
/customize.php?autofocus[section]=static_front_page
從哪裏去?
我經常發現自己需要從 WordPress 管理菜單中的外觀菜單項。也許這對你也有幫助:
add_action( 'admin_menu', 'wpse_custom_submenu_page' );
function wpse_custom_submenu_page() {
add_submenu_page(
'themes.php',
__( 'Page title', 'textdomain' ),
__( 'Menu title', 'textdomain' ),
'manage_options',
'/customize.php?autofocus[section]=section_name'
);
}
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。