WordPress主题会根据不同情况显示不同内容,这时候就会使用到WordPress内置的判断函数,这些函数大多以 “is_”开头,很容易就能理解,那么如何判断WordPress页面类型?其实很简单,加一个判断:
<?php
//判断开始
if(is_front_page() || is_home() || is_page() || is_category()) {
//如果是首页、页面、文章目录才会显示
?>
<div id=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”tag_cloud\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” class=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”widget\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”>
<h3>文章标签</h3>
<?php wp_tag_cloud(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’smallest=8&largest=14&number=12&order=RAND\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’); ?>
<div class=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”action\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”>
<a class=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”view-more\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”https://www.wpzt.net/<?php bloginfo(url);?>/all-tags/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”>View All Tags »</a>
</div>
</div>
<?php
};//判断结束位置
?>
许多其他的实用的衍生功能,在这里就不在赘述了。