2017-02-11 81 views
1

我剛剛瞭解瞭如何創建自定義WordPress主題。我想爲我的側欄指定一個類來創建樣式,但是我沒有在網上找到任何解釋如何執行此操作的內容。我加入到我的functions.php文件中的代碼註冊我的側邊欄是:如何在WordPress中爲自定義邊欄添加一個類

 
    if (function_exists('register_sidebar')) 
    register_sidebar(array(
     'id'   => 'sidebar-1', 
     'description' => __('Add widgets here to appear in your sidebar.', 'twentysixteen'), 
     'before_widget' => '', 
     'after_widget' => '', 
     'before_title' => '', 
     'after_title' => '', 
    )); 

我加入到我的sidebar.php文件中的代碼是:

<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) : ?> 
<?php endif; ?> 

任何幫助將不勝感激!

回答

1

使用before_widget和after_widget添加包裝。

1
register_sidebar(array(
     'name'   => esc_html__('Sidebar', 'twentysixteen'), 
     'id'   => 'sidebar-1', 
     'description' => 'Add widgets here to appear in your sidebar.', 
     'before_widget' => '<aside id="%1$s" class="widget custom-class %2$s">', 
     'after_widget' => '</aside>', 
     'before_title' => '<h2 class="widget-title custom-class">', 
     'after_title' => '</h2>', 
    )); 

在functions.php文件試試這個

相關問題