2017-02-09 45 views
1

如何在您的欄目中添加側邊欄? 我有我的側邊欄:是否可以在您的部分中添加邊欄? WordPress,Theme Customizer

function register_my_widgets(){ 
register_sidebar(array(
    'name' => 'Block 1 to Slide 2', 
    'id' => 'homepage-sidebar', 
    'before_widget' => '<p class="homepage-widget-block">', 
    'after_widget' => '</p>', 
    'before_title' => '<h2 class="widgettitle">', 
    'after_title' => '</h2>', 
)); 

我有我的部分定製:

$wp_customize->add_section('example_section_one', array(
    'title' => 'Slide 2, 
    'priority' => '', 
    'capability' => 'edit_theme_options' 
)); 

所有部件陷入「小工具」的範疇。如何繞過它並將小部件添加到主題定製器中的部分?

是否可以在定製器中添加節中的節?

+0

你想用你的側邊欄做什麼,你需要在不同的部分展示它,而不是更直觀的「小工具」部分? 如果您可以更詳細地描述,也許我們可以嘗試一些解決方案 – shariqkhan

+0

@shariqkhan是的,我需要在不同的部分顯示側邊欄。 – Nixin777

+0

是的,我明白了。我所問的是,你有什麼樣的原因,你試圖在不同的部分展示。 你的思路有助於帶來解決方案 – shariqkhan

回答

0
$wp_customize->add_panel('shk_so42130318', array(
    'title'   => __('My Custom Sidebar section', 'dreamglutes') 
)); 

接下來,使用此過濾器:

function reassign_sidebar_panel($section_args, $section_id, $sidebar_id) { 
    $section_args['panel'] = 'shk_so42130318'; 
    return $section_args; 
} 
add_filter('customizer_widgets_section_args', 'reassign_sidebar_panel',10,3); 

注意這個作品,如果你要添加工具條中的面板。 如果你需要在一個部分(而不是面板)中顯示它們,那麼它將需要更多的編碼。但我相信這也可以做到。

相關問題