代码之家  ›  专栏  ›  技术社区  ›  Stephanie

如何使我的整个页脚显示在所有页面模板上?它目前只显示在主页上。使用wordpress

  •  1
  • Stephanie  · 技术社区  · 9 年前

    我正在使用Cherry Framework制作的Wordpress模板。完整的页脚仅显示在主页上。我希望它出现在所有页面类型上,这些页面类型大多是“全宽页面模板”。

    当我查看每个模板的PHP文件时,我可以看到的区别是:

    <?php do_action( 'cherry_after_home_page_content' ); ?>
    

    我似乎找不到哪里 cherry_after_home_page_content 已定义。这就是我要找的吗?我尝试将其复制到全宽页面模板中,但它不起作用。如果我完全不在基地,那么正确的方法是什么?

    无论模板类型如何,都显示在每页上的页脚。以下是屏幕截图:

    Footer that appears on every page regardless of template type

    全角页面模板中的代码:

    <?php
    /**
    * Template Name: Fullwidth Page
    */
    
    get_header(); ?>
    
    <div class="motopress-wrapper content-holder clearfix">
        <div class="container">
            <div class="row">
                <div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-wrapper-file="page-fullwidth.php" data-motopress-wrapper-type="content">
                    <div class="row">
                        <div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-title.php">
                            <?php get_template_part("static/static-title"); ?>
                        </div>
                    </div>
                    <div id="content" class="row">
                        <div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="loop" data-motopress-loop-file="loop/loop-page.php">
                            <?php get_template_part("loop/loop-page"); ?>
                        </div>
                    </div>
                </div>
                <?php do_action( 'cherry_after_home_page_content' ); ?>
            </div>
        </div>
    </div>
    
    <?php get_footer(); ?>
    

    只显示在主页上的完整页脚。以下是屏幕截图:

    Complete footer that only appears on the home page

    主页模板中的代码:

    <?php
    /**
    * Template Name: Home Page
    */
    
    get_header(); ?>
    
    <div class="motopress-wrapper content-holder clearfix">
        <div class="container">
            <div class="row">
                <?php do_action( 'cherry_before_home_page_content' ); ?>
                <div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-wrapper-file="page-home.php" data-motopress-wrapper-type="content">
                    <div class="row">
                        <div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-slider.php">
                            <?php get_template_part("static/static-slider"); ?>
                        </div>
                    </div>
                    <div class="row">
                        <div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-type="loop" data-motopress-loop-file="loop/loop-page.php">
                            <?php get_template_part("loop/loop-page"); ?>
                        </div>
                    </div>
                </div>
                <?php do_action( 'cherry_after_home_page_content' ); ?>
            </div>
        </div>
    </div>
    
    <?php get_footer(); ?>
    
    1 回复  |  直到 9 年前
        1
  •  0
  •   Stephanie    9 年前

    我发现了这一点,所以对于任何遇到同样问题的人来说。

    “cherry_after_home_page_content”与此无关。(事实上,我后来注意到,在上面粘贴的代码中,我意外地将粘贴的代码放入了不属于它的全宽页面模板中。哎呀!)

    无论如何,它只是在CSS中。如果您看到页脚小部件只出现在主页上,那么您的CSS中可能有以下内容:

    .home .footer .footer-widgets { display:block; }
    

    在您的子主题中,粘贴上面的代码,但将.home更改为您希望它显示的页面。对我来说,所有常规页面都是.page,博客是.blog,博客是.single post。

    希望能帮到别人!