条件 if 语句 / is_page 在 WordPress 3.0 中不起作用

发布于 2024-09-17 23:50:20 字数 783 浏览 2 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女情怀诗 2024-09-24 23:50:20

修好了!它将其放入

fixed it! it put this in<?php wp_reset_query(); ?>

风吹过旳痕迹 2024-09-24 23:50:20

代码看起来不错。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文