【发布时间】:2021-10-10 23:47:52
【问题描述】:
在我正在处理的网站上,我的页脚小部件出现了一个奇怪的问题。在我的本地环境中,小部件看起来很好,但在临时站点上,小部件没有出现。当我查看实时预览时,它说我有 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>© 2021 SiteName</span><span><a href="<?php echo site_url('/privacy-policy')
?>">Privacy Policy</a></span>
</div>
</footer>
<?php wp_footer(); ?>
</body>
</html>
【问题讨论】:
-
尝试检查外观>>小部件中的小部件是否放置正确?能见度设置是否正确?还要确保您没有关于网站托管的问题。也尝试一一停用插件并检查
-
都试过了。我只是尝试在现场环境中应用主题。它在那里工作得很好。所以我认为这一定与设置的暂存环境有关。
标签: wordpress