小部件区域未显示在 WordPress 暂存站点中

问题描述 投票:0回答:1

我正在处理的网站上的页脚小部件遇到了一个奇怪的问题。在我的本地环境中,小部件显示得很好,但在临时站点上,小部件不会出现。当我查看实时预览时,它说我有 3 个小部件区域,但它们没有出现在该页面上。它们位于 footer.php 文件中(显示在每个页面上),该文件正在运行并在屏幕上显示非小部件相关部分。就像我说的,它在我当地的环境中运行良好。有什么想法吗?

编辑:我忘了提及,当我在“外观”>“小部件”下查看它时,它说我的网站没有小部件区域。

另一个编辑:我在错误日志中发现了这些错误。在第一个中,我注意到 7.4。这是否意味着它正在加载 php 7.4?我使用 php 8 在本地构建了这个主题。这可能是问题所在吗?

[06-Aug-2021 13:13:51 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/cpanel/ea-php70/root/usr/lib64/php/modules/ixed.7.4.lin' - /opt/cpanel/ea-php70/root/usr/lib64/php/modules/ixed.7.4.lin: cannot open shared object file: No such file or directory in Unknown on line 0
[06-Aug-2021 13:14:48 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home3/growinj1/public_html/staging/8458/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php on line 104
[06-Aug-2021 13:15:33 UTC] PHP Warning:  array_merge(): Expected parameter 3 to be an array, bool given in /home3/growinj1/public_html/staging/8458/wp-includes/class-wp-customize-widgets.php on line 379
[06-Aug-2021 13:15:33 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home3/growinj1/public_html/staging/8458/wp-includes/class-wp-customize-widgets.php on line 426

这是我的functions.php:


    <?php 
        function smm_files() {
            wp_enqueue_script('header-js', get_theme_file_uri('/js/header.js'), NULL, '1.0.0', true);
            wp_enqueue_style('main-styles', get_stylesheet_uri());
            wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css2?family=Arsenal:ital,wght@0,400;0,700;1,400&display=swap');
        }
        add_action('wp_enqueue_scripts', 'smm_files');
    
        function smm_features() {
            add_theme_support('title-tag');
            register_nav_menu('headerMenuLocation', 'Header Menu Location');
        }
        add_action('after_setup_theme', 'smm_features');
    
        function smm_widgets_init() {
    
            register_sidebar( array(
                'name' => 'Footer Sidebar 1',
                'id' => 'footer-sidebar-1',
                'description' => 'Appears in the footer area',
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                'after_widget' => '</aside>',
                'before_title' => '<h3 class="widget-title">',
                'after_title' => '</h3>',
                ) );
                register_sidebar( array(
                'name' => 'Footer Sidebar 2',
                'id' => 'footer-sidebar-2',
                'description' => 'Appears in the footer area',
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                'after_widget' => '</aside>',
                'before_title' => '<h3 class="widget-title">',
                'after_title' => '</h3>',
                ) );
                register_sidebar( array(
                'name' => 'Footer Sidebar 3',
                'id' => 'footer-sidebar-3',
                'description' => 'Appears in the footer area',
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                'after_widget' => '</aside>',
                'before_title' => '<h3 class="widget-title">',
                'after_title' => '</h3>',
                ) );
        }
        add_action( 'widgets_init', 'smm_widgets_init' );
    
        function smm_post_thumbnails() {
            add_theme_support( 'post-thumbnails' );
        }
        add_action( 'after_setup_theme', 'smm_post_thumbnails' );
    
    //Page Slug Body Class
    function add_slug_body_class( $classes ) {
        global $post;
        if ( isset( $post ) ) {
        $classes[] = $post->post_type . '-' . $post->post_name;
        }
        return $classes;
        }
        add_filter( 'body_class', 'add_slug_body_class' );

这是 footer.php:

        <footer>
            <div id="footer-sidebar" class="secondary">
                <div id="footer-sidebar1">
        <?php
            if(is_active_sidebar('footer-sidebar-1')){
                dynamic_sidebar('footer-sidebar-1');
            } endif;
        ?>
                </div>
                <div id="footer-sidebar2">
        <?php
            if(is_active_sidebar('footer-sidebar-2')){
                dynamic_sidebar('footer-sidebar-2');
            } endif;
        ?>
                </div>
                <div id="footer-sidebar3">
        <?php
            if(is_active_sidebar('footer-sidebar-3')){
                dynamic_sidebar('footer-sidebar-3');
            } endif;
        ?>
                </div>
            </div>
            <div class="bottom-el">
                <span>&copy 2021 SiteName</span><span><a href="<?php echo site_url('/privacy-policy') 
                            ?>">Privacy Policy</a></span>
            </div>
        </footer>
<?php wp_footer(); ?>
    </body>
</html>
php wordpress
1个回答
0
投票

我认为问题在于暂存站点设置为“site-domain.com/staging/8458”。

它在实时站点上运行良好,因此这一定是Wordpress查看暂存站点位置的方式。

© www.soinside.com 2019 - 2024. All rights reserved.