我在 header.php 中有一个测试,看看我们是否在家显示英雄。
<?php if ( is_home() && have_posts() ) : ?>
<div id="hero" class="inner clearfix">
...
</div>
<?php endif ?>
但是当用户登陆index.php时,英雄并没有被显示。
显然没有 is_index() 条件,有谁知道我如何测试它的主页或索引?
Try is_front_page()
<?php if ( is_home() || is_front_page() ) : ?>
<div id="hero" class="inner clearfix">
...
</div>
<?php endif ?>
如果您位于网站的绝对根目录上,则应该返回 true。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)