【问题标题】:WP get_footer function does not show footerWP get_footer 函数不显示页脚
【发布时间】:2018-08-31 14:25:45
【问题描述】:

我正在尝试学习如何构建自己的 WordPress 主题。我已经完成了一些教程,但我遇到了障碍。我似乎无法弄清楚我做错了什么。当我将页脚的 html 放在与“home.php”相同的文件中时,它可以正常工作。但是,当我尝试将其分开并将页脚 html 放在“footer.php”中并使用“get_footer();”时功能,页脚根本不出现,可见或在代码中......它不存在。我想知道是否还有其他事情我忽略了让页脚工作?如果不是,那么当我将代码拆分为不同的主题部分/文件时,可能导致页脚不显示的原因是什么?

这是 home.php 的代码:

    <?php
/*
  Template Name: Front Page
 */
?>

<?php get_header(); ?>

<?php get_template_part('nav'); ?>

<div id="content"><!-- Start Content -->

    <?php get_sidebar('left'); ?>

    <div id="middle-column" class="grid_8"><!-- Main Content Begins Here -->

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?><!-- Start Loop -->
                <div class="post">
                    <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
                    <div class="entrytext">
                        <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
                    </div>
                </div>
                <?php
            endwhile;
        else:
            ?>
            <?php _e('This page does not appear to have been set up yet. Sorry, please try again later. Thanks!'); ?>
        <?php endif; ?>

        <!-- End Loop -->

    </div>

    <?php get_sidebar('right'); ?>
    <?php get_footer(); ?>

这是footer.php的代码:

<div style="clear:both;"></div>
    <div id="push"></div>
</div><!-- End Content -->
</div><!-- End Container -->
</div><!-- End Wrapper -->


<div id="footer"><!-- Start Footer -->
    <div id="footWrap"><!-- Start #footWrap -->
        <p>&copy; Brent Blackwood</p>
    </div><!-- End #footWrap -->
</div><!-- End Footer -->

<div id="headerBand"></div><!-- Placed here for SEO purposes -->
<div id="navBand"></div><!-- Placed here for SEO purposes -->

</body>
</html>

【问题讨论】:

    标签: wordpress wordpress-theming footer


    【解决方案1】:

    我看不出有什么明显的错误。

    你的 wp-config.php 中有 define('WP_DEBUG',true); 吗?如果没有,请添加它并查看是否有可能有帮助的错误。

    你确定它在get_footer() 失败,而不是之前失败,例如get_sidebar()?

    你的“首页”模板文件和footer.php在同一个目录吗?

    你有公共网址吗?

    【讨论】:

    • 感谢您的帮助,尽管我确实添加了 WP_DEBUG 并检查了是否不是代码的另一部分破坏了它,但我仍然遇到问题。似乎是 get_footer 打破了它。 Front Page模板和footer.php在同一个目录下。没有公共网址,因为我正在使用 MAMP。对不起,但感谢您的帮助。
    • 好的。开始寻找functions hooked to get_footer。在您的主题和插件的源代码中搜索add_action('get_footer 或add_action( 'get_footer 或相同的双引号。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 2014-03-03
    • 2013-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多