Php 如何使用if语句在某些页面上显示页脚内容

Php 如何使用if语句在某些页面上显示页脚内容,php,html,Php,Html,我是php新手,我只想在2页上显示特定的页脚内容 我知道我会使用if语句,但我不知道在php中是否有办法知道显示的是什么页面 下面是footer.php <?php /** * The template for displaying the footer. * * Contains the closing of the id=main div and all content after * * @package WordPress * @subpackage Twenty_El

我是php新手,我只想在2页上显示特定的页脚内容

我知道我会使用if语句,但我不知道在php中是否有办法知道显示的是什么页面

下面是footer.php

<?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the id=main div and all content after
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
?>

    </div><!-- #main -->

    <footer id="colophon" role="contentinfo">

            <?php
                /* A sidebar in the footer? Yep. You can can customize
                 * your footer with three columns of widgets.
                 */
                get_sidebar( 'footer' );
            ?>

            <div class="boli-better">
<h1 class="description-title">WHY IS BOLI BETTER?</h1>
<div class="feature feature-item-248"><img class="main" src="http://www.btylus.com/wp-content/uploads/uclaproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PERFECTLY WEIGHTED</h2>
</div>
<div class="feature_description_content">

Touch screens have simplified technology, but there has yet to be a way to capture the precision of a calligrapher or the stroke of an artist. Not only should it meet your needs, but a stylus should have style.

</div>
</div>
</div>
<div class="feature feature-item-252"><img class="main" src="http://www.bylus.com/wp-content/uploads/bolitip.png" alt="" width="640" height="301" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PEN-LIKE PRECISION</h2>
</div>
<div class="feature_description_content">

Your stylus should be as sharp as your ideas. The thin and clear disc gives you the accuracy you want in a digital pen.

</div>
</div>
</div>
<div class="feature feature-item-254">

<img class="main" src="http://www.bylus.com/wp-content/uploads/blueproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">BALL POINT</h2>
</div>
<div class="feature_description_content">

Hold your stylus at the angle you’re most comfortable with. Jot gives you the freedom to write or sketch like you’re used to.

</div>
</div>
</div>
<div class="feature feature-item-256">

<img class="main" src="http://www.btylus.com/wp-content/uploads/greenproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">HEAVY METAL</h2>
</div>
<div class="feature_description_content">

Once Jot is in your grip, the quality is unmistakable. The durable aluminum and steel gives Jot superior conductivity and craftsmanship comparable to any luxury pen.

</div>
</div>
</div>
</div>

            <div id="site-generator">

                <strong id="footertext">Copyright Boli Stylus 2011</strong> 
                <a href="http://www.blus.com/contact-us" id="footertext" title="Contact Us">Contact Us</a> 
                <a href="http://www.btylus.com/terms" id="footertext" title="Terms">Terms</a>
            </div>
    </footer><!-- #colophon -->
</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>

为什么博利更好?
完全加权
触摸屏简化了技术,但至今还没有一种方法可以捕捉书法家的精准度或艺术家的笔触。它不仅应该满足你的需要,而且笔应该有风格。
笔式精度
你的手写笔应该和你的想法一样锋利。薄而清晰的光盘为您提供数字笔所需的准确度。
圆珠笔
以您最舒适的角度握住手写笔。Jot给你自由写作或素描,就像你习惯的那样。
重金属
一旦你掌握了这一点,质量就不会有错。耐用的铝和钢赋予Jot优越的导电性和工艺,可与任何豪华笔媲美。
版权所有Boli手写笔2011
好的,这就是我想出来的,但是当我将这段代码添加到footer.php时,整个页脚不会出现在网站上

我肯定我犯了一个基本的错误,所以提前谢谢你的帮助

<?php

$page = 'shop';
if (is_page($page)) { ?>

<div class="boli-better">
<h1 class="description-title">WHY IS BOLI BETTER?</h1>
<div class="feature feature-item-248"><img class="main" src="http://www.bylus.com/wp-content/uploads/uclaproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PERFECTLY WEIGHTED</h2>
</div>
<div class="feature_description_content">

Touch screens have simplified technology, but there has yet to be a way to capture the precision of a calligrapher or the stroke of an artist. Not only should it meet your needs, but a stylus should have style.

</div>
</div>
</div>
<div class="feature feature-item-252"><img class="main" src="http://www.bylus.com/wp-content/uploads/bolitip.png" alt="" width="640" height="301" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PEN-LIKE PRECISION</h2>
</div>
<div class="feature_description_content">

Your stylus should be as sharp as your ideas. The thin and clear disc gives you the accuracy you want in a digital pen.

</div>
</div>
</div>
<div class="feature feature-item-254">

<img class="main" src="http://www.btylus.com/wp-content/uploads/blueproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">BALL POINT</h2>
</div>
<div class="feature_description_content">

Hold your stylus at the angle you’re most comfortable with. Jot gives you the freedom to write or sketch like you’re used to.

</div>
</div>
</div>
<div class="feature feature-item-256">

<img class="main" src="http://www.bylus.com/wp-content/uploads/greenproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">HEAVY METAL</h2>
</div>
<div class="feature_description_content">

Once Jot is in your grip, the quality is unmistakable. The durable aluminum and steel gives Jot superior conductivity and craftsmanship comparable to any luxury pen.

</div>
</div>
</div>
</div>;

<?php 
}
?>

为什么博利更好?
完全加权
触摸屏简化了技术,但至今还没有一种方法可以捕捉书法家的精准度或艺术家的笔触。它不仅应该满足你的需要,而且笔应该有风格。
笔式精度
你的手写笔应该和你的想法一样锋利。薄而清晰的光盘为您提供数字笔所需的准确度。
圆珠笔
以您最舒适的角度握住手写笔。Jot给你自由写作或素描,就像你习惯的那样。
重金属
一旦你掌握了这一点,质量就不会有错。耐用的铝和钢赋予Jot优越的导电性和工艺,可与任何豪华笔媲美。
;
看看PHP的。您可能正在查找
$\u服务器['REQUEST\u URI']

if ($_SERVER['REQUEST_URI'] == "/index.php") {
   echo "My stuff to show on /index.php";
}

您可以在希望检查的页面上设置一个特殊变量(并在页脚的if语句中使用),或者使用@Christofer Eliasson的答案,该答案使用服务器的请求URI变量检查WP代码。我想说的是,_page()就是你想要的:

你想要的是:

<?php
     if (is_page(array('page1','page2'))) {
       <!-- Fotter content displayed here --> 
     }
?>


请发布与问题相关的代码。理想情况下,除了问题正文中的代码之外,请添加问题的示例。它将帮助我们帮助您。如果您可以查看,我使用is_page()将失败的代码添加到问题中。我不认为它是这样工作的,您不需要设置变量。WP会帮你解决的。请阅读:我认为它与文件名不匹配,而是与slug名称匹配。来自Codex:“当显示带有“关于我”的帖子名(slug)的页面时,是页面('about me')。@nearyprgrm不幸的是,我没有WP的经验,但根据文档,我最好的猜测是:
WP_reset_query();如果(是页面(“商店”){//做你的事}
。您是否尝试过我的示例,但没有使用WP特定的函数?@nearyorprgrm Sweet!很乐意帮忙。