2014-09-06 57 views
1

我需要爲主題註冊邊欄。 我已經添加了這個代碼結束的functions.phpregister_sidebar和白色屏幕錯誤

<?php 
include("widget.php"); 
function farad_widgets_init(){ 
register_sidebar(array(
     'id' => 'sidebar-1', 
     'name' => 'left-sidebar', 
     'description' => 'farad' , 
     'before_widget' => '<aside id="%1$s" class="widget %2$s">', 
     'after_widget' => "</aside>", 
     'before_title' => '<h2 class="widget-title">', 
     'after_title' => '</h2>', 
    )); 
} 
add_action('widgets_init', 'farad_widgets_init'); 
?> 

後,我已經添加了代碼,WP-login.php中告訴我一個白色的屏幕。

有什麼問題?

+0

可能是一個錯誤沒有顯示。你有沒有試過打開錯誤報告? – Boaz 2014-09-06 07:03:27

+0

鏈接不可訪問。你應該在你的文章中包含錯誤。 – Boaz 2014-09-06 07:12:13

+0

我在本地主機上沒有問題。但在主服務器我面對這些錯誤。 – Miller 2014-09-06 07:12:41

回答

1

刪除打開和關閉php(<?php ?>)標記。你最有可能沒有關閉你的php標籤後的最後一個功能,所以添加你的代碼,因爲你創建了一個語法錯誤,因爲你已經打開php標籤內的開放php標籤

另外,刪除include()部分,這是沒有必要的

0

只需將此代碼在function.php中,您將獲得左側邊欄。

function farad_widgets_init(){ 
register_sidebar(array(
     'id' => 'sidebar-1', 
     'name' => 'left-sidebar', 
     'description' => 'farad' , 
     'before_widget' => '<aside id="%1$s" class="widget %2$s">', 
     'after_widget' => "</aside>", 
     'before_title' => '<h2 class="widget-title">', 
     'after_title' => '</h2>', 
    )); 
} 
add_action('widgets_init', 'farad_widgets_init');