2017-05-08 52 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 
} 
相关问题