2013-12-14 78 views
0

我用下面的PHP代碼註冊一個側邊欄:WordPress的側邊欄部件不被WordPress的渲染正確

register_sidebar(array(
    'name' => 'Owner\'s main page intro left sidebar.', 
    'id' =>  'main-left-sidebar', 
    'description' => 'This is the main side bar of the theme i.e. the information of the author on the index page will be displayed using it. Note: It MUST have a single text widget or otherwise it may distort the theme', 
    'before_widget' => '', 
    'after_widget' => '</p>', 
    'before_title' => '<div class="porse"><h3 id="titlehead">', 
    'after_title' => '</h3></div><p class="porse-lead">' 
)); 

所以,當我添加窗口小部件(我有一個文本組件工作),它產生類似如下:

<div class="porse"> 
    <h3 id="titlehead">I'm Kamran Ahmed</h3> 
</div> 
<p class="porse-lead">I make websites. I help small businesses, start-ups, individuals, and fellow web agencies make the most of their web presence.</p> 

但每當我添加窗口小部件到側邊欄,它不斷地產生以下標記:

<div class="porse"> 
    <h3 id="titlehead">I am Kamran Ahmed</h3> 
</div> 
<p class="porse-lead">   </p> 
<div class="textwidget">I make websites. I help small businesses, start-ups, individuals, and fellow web agencies make the most of their web presence.</div> 
<p></p> 

任何人都可以請告訴我,我在這裏做錯了什麼。爲什麼它不產生我想要的標記?

回答

0

您不能在<p>標籤內使用<div>標籤。

試試這個:

register_sidebar(array(
    'name' => 'Owner\'s main page intro left sidebar.', 
    'id' =>  'main-left-sidebar', 
    'description' => 'This is the main side bar of the theme i.e. the information of the author on the index page will be displayed using it. Note: It MUST have a single text widget or otherwise it may distort the theme', 
    'before_widget' => '', 
    'after_widget' => '</div>', 
    'before_title' => '<div class="porse"><h3 id="titlehead">', 
    'after_title' => '</h3></div><div class="porse-lead">' 
)); 
+0

因爲,如果我把它放在'before_widget',這將封閉整個部件(包括標題),我不想。 –

+0

我已更新答案。請嘗試此操作並將結果報告給我們。正在生成'

',因爲您在WordPress中使用了文本小部件。 –

+0

工作。謝謝。 –