边栏的额外副本显示在页脚中

时间:2021-05-06 作者:posfan12

我有一个额外的边栏内容副本,显示在最后一篇文章之后,输出HTML中的页脚之前。所以我有一个在正确位置的侧面,还有一个在页面的末尾。有没有办法去掉第二个?

功能。php

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function isometricland_widgets_init() {
    register_sidebar( array(
        \'name\'          => esc_html__( \'Sidebar\', \'isometricland\' ),
        \'id\'            => \'sidebar-1\',
        \'description\'   => esc_html__( \'Add widgets here.\', \'isometricland\' ),
        \'before_widget\' => \'<section id="%1$s" class="widget %2$s">\',
        \'after_widget\'  => \'</section>\',
        \'before_title\'  => \'<h2 class="widget-title">\',
        \'after_title\'   => \'</h2>\',
    ) );
}
add_action( \'widgets_init\', \'isometricland_widgets_init\' );
页脚。php

<?php
    global $path_root, $page_title, $path_img, $path_ssi, $path_css, $path_jav;
    include_once($path_ssi . \'plugin-paypal.php\');
    include_once($path_ssi . \'plugin-sitesearch.php\');
    include_once($path_ssi . \'plugin-socialicons.php\');
    include_once($path_ssi . \'plugin-norml.php\');
?>
                </main>
                <!-- END PAGE CONTENTS -->
                <!-- START FOOTERS -->
                <div id="footframe">
                    <footer>
                        <div><small><?php printf( __( \'Proudly powered by %s.\', \'isometricland\' ), \'WordPress\' ); ?> <?php printf( __( \'Theme: %1$s by Michael Horvath based on %2$s GPLv2 or later.\', \'isometricland\' ), \'isometricland\', \'<a href="http://underscores.me/" rel="designer">Underscores.me</a>\' ); ?></small></div>
                        <div><small>&gt;&gt;&gt;<a href="https://isometricland.net/pages/sitemap.php">sitemap</a>&lt;&lt;&lt;</small></div>
                    </footer>
<?php wp_footer(); //Crucial footer hook! ?>
                </div>              
                <!-- END FOOTERS -->
            </div>
            <!-- END MIDDLE PANE -->
            <!-- START SIDEBAR -->
            <div id="leftframe">
                <div id="sidebarframetop">
                    <div id="sidebar_widget">
<?php dynamic_sidebar( \'sidebar-1\' ); ?>
                    </div>
                </div>
                <div id="sidebarframebot">
                    <div id="file_paypal">
<?php //echo writePaypalDonate(); ?>
                    </div>
                    <div id="file_search">
<?php //echo writeSiteSearchForm(); ?>
                    </div>
                    <div id="file_social">
<?php echo writeSocialIcons(); ?>
                    </div>
                    <div id="file_norml">
<?php //echo writeNormlLogo(); ?>
                    </div>
                </div>
            </div>
            <!-- END SIDEBAR -->
        </div>
    </body>
</html>
标题。php

<?php
    global $path_root, $page_title, $path_img, $path_ssi, $path_css, $path_jav;
    include_once($path_ssi . \'plugin-analyticstracking.php\');
    include_once($path_ssi . \'plugin-verytopbar.php\');
?>
<!DOCTYPE HTML>
<html <?php language_attributes(); ?>>
    <head>
<?php echo writeAnalyticsTracking(); ?>
        <meta charset="<?php bloginfo(\'charset\'); ?>">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="profile" href="http://gmpg.org/xfn/11">
        <link rel="pingback" href="<?php bloginfo(\'pingback_url\'); ?>">
        <link rel="alternate" href="<?php bloginfo(\'rss2_url\'); ?>" title="<?php bloginfo(\'name\'); ?> RSS Feed" type="application/rss+xml" />
        <link type="text/css" rel="stylesheet" href="<?php echo $path_css; ?>style-main.css"/>
        <link type="text/css" rel="stylesheet" href="<?php echo $path_css; ?>style-dropdown.css"/>
        <link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
        <link rel="icon" type="image/png" href="<?php echo $path_root; ?>favicon.png"/>
        <script src="<?php echo $path_jav; ?>dropdown.js"></script>
        <script src="<?php echo $path_jav; ?>cubesnake.js"></script>
<?php wp_head(); ?>
    </head>
    <body onload="">
        <div id="seed_pane"><img id="seed_image" src="https://isometricland.net/svg/seed_of_life_monochrome.svg"/></div>
        <div id="snake_pane"></div>
        <div id="outerframe">

            <!-- START MIDDLE PANE -->
            <div id="middleframe">
                <!-- START FAUX WP ADMIN BAR -->
                <div id="verytopbar">
                    <nav role="navigation">
<?php echo writeVeryTopBar(); ?>
                    </nav>
                </div>
                <!-- END FAUX WP ADMIN BAR -->
                <!-- START PAGE CONTENTS -->
                <main>
侧栏。php

<?php
/**
 * The sidebar containing the main widget area
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Isometricland
 */

if ( ! is_active_sidebar( \'sidebar-1\' ) ) {
    return;
}
?>

<aside id="secondary" class="widget-area">
    <?php dynamic_sidebar( \'sidebar-1\' ); ?>
</aside><!-- #secondary -->
索引。php

<?php
    $path_root = "../../../../";
    $path_img = "../../../../images/";
    $path_css = "../../../../css/";
    $path_jav = "../../../../java/";
    $path_ssi = "../ssi/";
    $page_title = "Blog";
    include_once($path_ssi . \'directory.php\');
    include_once($path_ssi . \'getpageinfo.php\');
?>
<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Isometricland
 */

get_header();
?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">

        <?php
        if ( have_posts() ) :

            if ( is_home() && ! is_front_page() ) :
                ?>
                <header>
                    <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
                </header>
                <?php
            endif;

            /* Start the Loop */
            while ( have_posts() ) :
                the_post();

                /*
                 * Include the Post-Type-specific template for the content.
                 * If you want to override this in a child theme, then include a file
                 * called content-___.php (where ___ is the Post Type name) and that will be used instead.
                 */
                get_template_part( \'template-parts/content\', get_post_type() );

            endwhile;

            the_posts_navigation();

        else :

            get_template_part( \'template-parts/content\', \'none\' );

        endif;
        ?>

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

<?php
get_sidebar();
get_footer();
单身。php

<?php
    $path_root = "../../../../";
    $path_img = "../../../../images/";
    $path_css = "../../../../css/";
    $path_jav = "../../../../java/";
    $path_ssi = "../ssi/";
    $page_title = "Blog";
    include_once($path_ssi . \'directory.php\');
    include_once($path_ssi . \'getpageinfo.php\');
?>
<?php
/**
 * The template for displaying all single posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package Isometricland
 */

get_header();
?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">

        <?php
        while ( have_posts() ) :
            the_post();

            get_template_part( \'template-parts/content\', get_post_type() );

            the_post_navigation();

            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) :
                comments_template();
            endif;

        endwhile; // End of the loop.
        ?>

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

<?php
get_sidebar();
get_footer();
侧边栏的两个副本的屏幕截图。

screenshot

1 个回复
最合适的回答,由SO网友:Jacob Peattie 整理而成

如果您查看问题中包含的所有模板,原因很明显:您输出了两次侧栏。

在索引中。您使用的phpget_sidebar(), 哪个装载sidebar.php. 在该模板中,您将输出小部件:

<aside id="secondary" class="widget-area">
    <?php dynamic_sidebar( \'sidebar-1\' ); ?>
</aside><!-- #secondary -->
您还使用get_footer(), 哪个装载footer.php. 在该模板中,您还可以输出小部件:

                    <div id="sidebar_widget">
<?php dynamic_sidebar( \'sidebar-1\' ); ?>
                    </div>

相关推荐

Searchresult sidebar change

那么,searchresult页面侧栏位于哪里?例如,在searchresult页面中,有一个“A”侧栏。但是,我想将其更改为“B”侧栏。我看着search.php 但无法理解侧边栏的来源。