2016-02-11 40 views
0

我使用這個wordpress主題https://wordpress.org/themes/sleeky/,我想包括一個新的窗口小部件。自定義wordpress主題,以包含一個新的窗口小部件

我想要這個的原因是我想要一個col-xs-12小部件大小的文本直接在橫幅下面。隨後是3個col-xs-4盒子......但我發現用這個主題非常難以實現。

我的主題有'頂部'和'底部',每個部分有4個可能的部分。看起來,如果我只有一個小部件在'頂部',它會將它指定爲col-xs-12 - 完美!但是現在我想在它們自己的行下面安裝3個col-xs-4,但是我不能使用'top'小部件,因爲這樣可以將col-xs-12減少爲col-xs-3,因爲主題中的代碼如下:

// lets setup the inset top group 
    function sleeky_topgroup() { 
     $count = 0; 
     if (is_active_sidebar('top1')) 
      $count++; 
     if (is_active_sidebar('top2')) 
      $count++; 
     if (is_active_sidebar('top3')) 
      $count++;  
     if (is_active_sidebar('top4')) 
      $count++; 
     $class = ''; 
     switch ($count) { 
      case '1': 
       $class = 'col-md-12'; 
       break; 
      case '2': 
       $class = 'col-md-6'; 
       break; 
      case '3': 
       $class = 'col-md-4'; 
       break; 
      case '4': 
       $class = 'col-md-3'; 
       break; 
     } 
     if ($class) 
      echo $class; 
    } 

因此......我想包括另一個'中間'層,所以我可以使用'top'和1個元素,給它col-xs-12,然​​後用3中間,這會給每個col -xs-4 :)

我已經找到了文件INC/sleeky_widgets.php,並改變它包括MID1,MID2,MID3,mid4選項....如下:

<?php 
/* 
================================================= 
sleeky Date Theme Widget Positions 
This Files will show widgets on the back end of the file 
@package sleeky 
================================================= 
*/ 
function sleeky_widgets_init() { 

    register_sidebar(array(
     'name' => __('Blog Sidebar', 'sleeky'), 
     'id' => 'blogright', 
     'description' => __('This is the right sidebar column that appears on the blog but not the pages.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><hr/>', 
    )); 
    register_sidebar(array(
     'name' => __('Page Sidebar', 'sleeky'), 
     'id' => 'pagesidebar', 
     'description' => __('This is the right sidebar column that appears on the blog but not the pages.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><hr/>', 
    )); 
    register_sidebar(array(
     'name' => __('Banner Wide', 'sleeky'), 
     'id' => 'banner-wide', 
     'description' => __('This is a full width showcase banner for images or media sliders that can display on your pages.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><hr/>' 
    )); 

    register_sidebar(array(
     'name' => __('Top 1', 'sleeky'), 
     'id' => 'top1', 
     'description' => __('This is the 1st top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Top 2', 'sleeky'), 
     'id' => 'top2', 
     'description' => __('This is the 2nd top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Top 3', 'sleeky'), 
     'id' => 'top3', 
     'description' => __('This is the 3rd top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Top 4', 'sleeky'), 
     'id' => 'top4', 
     'description' => __('This is the 4th top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    )); 

    register_sidebar(array(
     'name' => __('Mid 1', 'sleeky'), 
     'id' => 'mid1', 
     'description' => __('This is the 1st mid widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Mid 2', 'sleeky'), 
     'id' => 'mid2', 
     'description' => __('This is the 2nd top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Mid 3', 'sleeky'), 
     'id' => 'mid3', 
     'description' => __('This is the 3rd top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Mid 4', 'sleeky'), 
     'id' => 'mid4', 
     'description' => __('This is the 4th top widget position located just below the banner area.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    )); 
    register_sidebar(array(
     'name' => __('Bottom 1', 'sleeky'), 
     'id' => 'bottom1', 
     'description' => __('This is the first bottom widget position located in a coloured background area just above the footer.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Bottom 2', 'sleeky'), 
     'id' => 'bottom2', 
     'description' => __('This is the second bottom widget position located in a coloured background area just above the footer.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Bottom 3', 'sleeky'), 
     'id' => 'bottom3', 
     'description' => __('This is the third bottom widget position located in a coloured background area just above the footer.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    ));  
    register_sidebar(array(
     'name' => __('Bottom 4', 'sleeky'), 
     'id' => 'bottom4', 
     'description' => __('This is the fourth bottom widget position located in a coloured background area just above the footer.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h3><span class="dotbox"></span>', 
     'after_title' => '</h3><div class="dotlinebox"><span class="dot"></span></div>', 
    )); 
    register_sidebar(array(
     'name' => __('Call to Action', 'sleeky'), 
     'id' => 'cta', 
     'description' => __('This is a call to action which is normally used to make a message stand out just above the main content.', 'sleeky'), 
     'before_widget' => '<div id="%1$s" class="widget %2$s">', 
     'after_widget' => '</div>', 
     'before_title' => '<h2>', 
     'after_title' => '</h2>', 
    )); 

} 
add_action('widgets_init', 'sleeky_widgets_init'); 

/** 
* Count the number of widgets to enable resizable widgets 
*/ 

// lets setup the inset top group 
function sleeky_topgroup() { 
    $count = 0; 
    if (is_active_sidebar('top1')) 
     $count++; 
    if (is_active_sidebar('top2')) 
     $count++; 
    if (is_active_sidebar('top3')) 
     $count++;  
    if (is_active_sidebar('top4')) 
     $count++; 
    $class = ''; 
    switch ($count) { 
     case '1': 
      $class = 'col-md-12'; 
      break; 
     case '2': 
      $class = 'col-md-6'; 
      break; 
     case '3': 
      $class = 'col-md-4'; 
      break; 
     case '4': 
      $class = 'col-md-3'; 
      break; 
    } 
    if ($class) 
     echo $class; 
} 

function sleeky_middlegroup() { 
    $count = 0; 
    if (is_active_sidebar('mid1')) 
     $count++; 
    if (is_active_sidebar('mid2')) 
     $count++; 
    if (is_active_sidebar('mid3')) 
     $count++;  
    if (is_active_sidebar('mid4')) 
     $count++; 
    $class = ''; 
    switch ($count) { 
     case '1': 
      $class = 'col-md-12'; 
      break; 
     case '2': 
      $class = 'col-md-6'; 
      break; 
     case '3': 
      $class = 'col-md-4'; 
      break; 
     case '4': 
      $class = 'col-md-3'; 
      break; 
    } 
    if ($class) 
     echo $class; 
} 


// lets setup the content bottom group 
function sleeky_contentbottomgroup() { 
    $count = 0; 
    if (is_active_sidebar('contentbottom1')) 
     $count++; 
    if (is_active_sidebar('contentbottom2')) 
     $count++; 
    if (is_active_sidebar('contentbottom3')) 
     $count++;  
    if (is_active_sidebar('contentbottom4')) 
     $count++; 
    $class = ''; 
    switch ($count) { 
     case '1': 
      $class = 'dsp-md-12'; 
      break; 
     case '2': 
      $class = 'dsp-md-6'; 
      break; 
     case '3': 
      $class = 'dsp-md-4'; 
      break; 
     case '4': 
      $class = 'dsp-md-3'; 
      break; 
    } 
    if ($class) 
     echo 'class="' . $class . '"'; 
} 

// lets setup the bottom group 
function sleeky_bottomgroup() { 
    $count = 0; 
    if (is_active_sidebar('bottom1')) 
     $count++; 
    if (is_active_sidebar('bottom2')) 
     $count++; 
    if (is_active_sidebar('bottom3')) 
     $count++;  
    if (is_active_sidebar('bottom4')) 
     $count++; 
    $class = ''; 
    switch ($count) { 
     case '1': 
      $class = 'col-md-12'; 
      break; 
     case '2': 
      $class = 'col-md-6'; 
      break; 
     case '3': 
      $class = 'col-md-4'; 
      break; 
     case '4': 
      $class = 'col-md-3'; 
      break; 
    } 
    if ($class) 
     echo 'class="' . $class . '"'; 
} 

但是,當我查看添加新窗口小部件的側邊欄時 - 我沒有在那裏看到我的新選項。它看起來如下所示:

enter image description here如何使我的新窗口小部件顯示在此菜單中,並且行爲與系統中已定義的頂層和底層完全相同。

回答

0

擺弄周圍好以後,我發現了另一個名爲文件:側邊欄top.php

,加入後:

<div class="sleeky_widget_mid"> 
    <div class="container"> 
      <div class="row"> 
       <div id="mid1" class="<?php sleeky_middlegroup(); ?>" role="complementary"> 
        <?php dynamic_sidebar('mid1'); ?> 
       </div><!-- #top1 --> 

       <div id="mid2" class="<?php sleeky_middlegroup(); ?>" role="complementary"> 
        <?php dynamic_sidebar('mid2'); ?> 
       </div><!-- #top2 -->   

       <div id="mid3" class="<?php sleeky_middlegroup(); ?>" role="complementary"> 
        <?php dynamic_sidebar('mid3'); ?> 
       </div><!-- #top3 --> 

       <div id="mid4" class="<?php sleeky_middlegroup(); ?>" role="complementary"> 
        <?php dynamic_sidebar('mid4'); ?> 
       </div><!-- #top3 --> 

      </div> 
    </div> 
</div> 

我的菜單選項出現了奇妙的表現!

相關問題