如果不是,我如何从其他情况下排除 php 模板



我在我的网站上使用Wordpress,有一小部分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 }?>

我想从 ELSE 中排除"单ad_listing.php"模板,因为我想搜索此模板的侧边栏。我该怎么做?提前谢谢。

您可以检查是否正在显示单个页面,此外,您可以将帖子类型作为参数指定为特定。

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

相关内容

最新更新