2017-05-08 31 views
0

我在我的網站上使用Wordpress,並有一小段php代碼,我想從中排除一個php模板。我怎麼能排除一個PHP模板,如果其他

<?php if (is_user_logged_in()) { ?> 
.content_right { float: right !important; border-right:0px !important; border-left: 1px solid #EAE6E6 ;} 
.content_right .shadowblock_out { border-right:0px !important;} 
.content_left {float: left !important;} 
<?php } else { ?> 
.content_right {display:none} 
.content_right .shadowblock_out {display:none} 
.content_left {float: left !important; width: 100%;} 
.box {margin: 1px 4px; float: left; width: 24% !important;} 
.box .grido {display: block;height: 133px;margin: 2px 3px 5px;overflow: hidden;width: 210px;border: 1px solid #ebebeb;} 
#directory {width: 930px !important;} 

<?php }?> 

而且我想從別的排除「單ad_listing.php」模板,因爲我想shpw此模板的側邊欄。我該怎麼做? 在此先感謝。

回答

0

您可以檢查是否正在顯示單個頁面,還可以將帖子類型作爲參數進行指定。

if (is_singular("ad_listing")) { // here you need to put the post type 
    // what you want here 
} else { 
    // what you want elsewhere 
} 
相關問題