好,我只是使用引導開發了我的第一個自定義WordPress的主題 - 我還是個菜鳥。我沒有使用小工具填充側邊欄,我想用自己的代碼和圖像自己填寫。在WordPress我希望我的側邊欄來改變基於頁面
因此,可以說我想我做了只在主頁上顯示了第一個欄,然後我做了第二個欄顯示了所有其他網頁上。我可以使用if語句嗎?
<?php
if(is_home()){
echo
"<div class="row">
<div class="span3">
<div id="search-box"><img id="search_text" src="http://localhost/Dorsa/wp-content/themes/Bootstrap/img/text_findyourhome.png">
</div>
</div>
</div>
<div class="row">
<div class="span3">
<img class="box_shadow" src="http://localhost/Dorsa/wp-content/themes/Bootstrap/img/box-shadow.png" style="padding-left:0;">
</div>
</div>
<div class="row">
<div class="span3"><div id="news" style="margin-top:275px;margin-bottom:200px">News</div></div>
</div>"
}
else
{
echo
"sidebar 2 code - didn't write it yet"
}
?>
我會建議在PHP中使用模板和頁面而不是if語句。 http://codex.wordpress.org/Templates http://codex.wordpress.org/Pages – zajd