条件 if 语句 / is_page 在 WordPress 3.0 中不起作用
我已经尝试了很多变体,我知道当我放入 is_home 时这会起作用,尽管这不是我想要实现的目标,但它会在每个页面上显示它......如果我尝试其他任何东西,例如 is_front_page 或类似的东西我在下面的例子中,这就是我实际上想要实现的目标,但它不起作用(工作!)。有人可以帮忙吗?
<?php if (is_page('about')) { ?>
<div id="testimonial-block" class="sidebar-block clearfix">
<h4>Testomonials</h4>
<p>"I feel so much more motivated and in control of my life. The coaching has given me the time to think about what I really wanted to achieve and how I can make it happen. I have been completely blown away by how much I have enjoyed coaching with Becky and embraced the concept across my whole life."<br />
<small>Caroline Rowe, <br />
Communications Manager</small></p>
</div>
<?php } ?>
I've tried a number of variations and I know this works when I put in is_home even though that's not what I'm trying to achieve but it displays it on every page.... if I try anything else like is_front_page or like what I have in the example below which is what I'm actually trying to achieve then it doesn't (work!). Can anyone help please?
<?php if (is_page('about')) { ?>
<div id="testimonial-block" class="sidebar-block clearfix">
<h4>Testomonials</h4>
<p>"I feel so much more motivated and in control of my life. The coaching has given me the time to think about what I really wanted to achieve and how I can make it happen. I have been completely blown away by how much I have enjoyed coaching with Becky and embraced the concept across my whole life."<br />
<small>Caroline Rowe, <br />
Communications Manager</small></p>
</div>
<?php } ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
修好了!它将其放入
fixed it! it put this in
<?php wp_reset_query(); ?>
代码看起来不错。
is_page() 函数进行区分大小写的字符串比较(我相信)。
检查字母大小写..并看看它是否有效。
the code looks fine.
the is_page() function does a case-sensitive string comparison ( i believe).
Check for the letter casing.. and see if it works.