2012-01-28 83 views
0

我正在創建WP主題,並遇到問題。我想和小部件的動態側邊欄,並因此創造的sidebar.php這樣WordPress主題側欄小部件問題

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

<?php endif; ?> 

而且在functions.php中我寫了這個現在

<?php 
if (function_exists('register_sidebar')) 
register_sidebar(); 
?> 

,WordPress的說,「主題」頁面上的在函數下,小部件是可用的,但是當我導航到小部件時,我得到錯誤「無側邊欄定義」。在我的index.php中,我添加了「get_sidebar()」這一行。

什麼可能導致這種情況,我該如何解決?

回答

1

嘗試像這樣指定名稱的註冊欄:

<?php register_sidebar(array('name'=>'sidebar1',)); ?> 

然後調用它的模板文件是這樣的:

<?php if (function_exists (dynamic_sidebar(1))) : ?> 
<?php dynamic_sidebar (1); ?> 
<?php endif; ?>