2016-03-01 70 views
-2

請有人告訴我如何做到這一點?我的主題(寓言)沒有內置的邊欄,我需要一個用於我的主頁。如何爲沒有側邊欄的主題創建窗口化邊欄?

非常感謝!

+1

你試過了什麼?你在哪裏看?爲什麼它不起作用? – Auzias

+0

如果你的主題沒有提供側邊欄,你可以1)停止使用它,並移動到完全不同的邊欄和2)停止使用它,並創建一個邊欄的兒童主題。我沒有看到第三個選項。 –

回答

0
  1. 創建一個兒童主題。
  2. 創建一個文件sidebar.php。

  3. 在你的sidebar.php文件必須至少使用以下功能:在你的孩子的主題,您必須使用以下功能您functions.php文件dynamic_sidebar()

  4. 此外:register_sidebar()

  5. 將邊欄添加到您的子主題中(最有可能在被覆蓋的index.php文件中)

  6. 設計側邊欄以將其與主題正確集成。

如需進一步資料看WordPress的法典:

https://codex.wordpress.org/Child_Themes https://codex.wordpress.org/Function_Reference/dynamic_sidebar https://codex.wordpress.org/Function_Reference/register_sidebar

0

在functions.php文件將這個:

<?php 
// Declare sidebar widget zone 
register_sidebars(1, 
array(
    'name' => 'My Widget Area', 
    'before_widget' => '<div id="%1$s" class="widget %2$s">', 
    'after_widget' => '</div>', 
    'before_title' => '<h3 class="widgettitle">', 
    'after_title' => '</h3>' 
    ) 
    ); 
?> 

然後把這個地方在你想要顯示小部件區域的主題中:

<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('My Widget Area')) : else : ?><?php endif; ?>