错误 500:PHP 致命错误:无法重新声明 thim_widgets_inits()



我的页面 tolkeuddannelsen.dk 收到错误500。通过错误日志,我可以知道它的主题功能中的第 93-185 行.php这导致了麻烦。这是我的网络主机说的: 后端致命错误:PHP 致命错误:无法在第 185 行重新声明 thim_widgets_inits(((以前在/var.php/www/www.tolkeuddannelsen.dk/www/functions.php:93 中声明(,引用:http://tolkeuddannelsen.dk/

这些行中的代码如下所示。

function thim_widgets_inits() {
    register_sidebar( array(
        'name'          => __( 'Sidebar 1', 'thim' ),
        'id'            => 'sidebar-1',
        'description'   => 'Left Sidebar',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
//  register_sidebar( array(
//      'name'          => __( 'Sidebar 2', 'thim' ),
//      'id'            => 'sidebar-2',
//      'description'   => 'Right Sidebar',
//      'before_widget' => '<aside id="%1$s" class="widget %2$s">',
//      'after_widget'  => '</aside>',
//      'before_title'  => '<h4 class="widget-title">',
//      'after_title'   => '</h4>',
//  ) );
    register_sidebar( array(
        'name'          => 'Top Drawer',
        'id'            => 'drawer_top',
        'description'   => __( 'Drawer Top', 'thim' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => __( 'Offcanvas', 'thim' ),
        'id'            => 'offcanvas_sidebar',
        'description'   => 'Drawer Right',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => 'Menu Right',
        'id'            => 'menu_right',
        'description'   => __( 'Menu Right', 'thim' ),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget'  => '</li>',
        'before_title'  => '<h3>',
        'after_title'   => '</h3>',
    ) );
    register_sidebar( array(
        'name'          => 'Footer',
        'id'            => 'footer',
        'description'   => __( 'Footer Sidebar', 'thim' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s footer_widget">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => 'Copyright',
        'id'            => 'copyright',
        'description'   => __( 'Copyright', 'thim' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => __( 'Sidebar Shop', 'thim' ),
        'id'            => 'shop',
        'description'   => 'Shop Sidebar',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    if ( class_exists( 'LearnPress' ) ) {
        register_sidebar( array(
            'name'          => 'Top Sidebar Courses',
            'id'            => 'top_sidebar_courses',
            'description'   => __( 'Top Sidebar Courses', 'thim' ),
            'before_widget' => '',
            'after_widget'  => '',
            'before_title'  => '<h3>',
            'after_title'   => '</h3>',
        ) );
        register_sidebar( array(
            'name'          => 'Sidebar Courses',
            'id'            => 'sidebar_courses',
            'description'   => __( 'Sidebar Courses', 'thim' ),
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h4 class="widget-title">',
            'after_title'   => '</h4>',
        ) );
    }
}

谁能帮我解决这个问题?谢谢!

这是因为您正在重新声明已经声明的函数。

使用这个:

function thim_widgets_inits_child() {
    register_sidebar( array(
        'name'          => __( 'Sidebar 1', 'thim' ),
        'id'            => 'sidebar-1',
        'description'   => 'Left Sidebar',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
//  register_sidebar( array(
//      'name'          => __( 'Sidebar 2', 'thim' ),
//      'id'            => 'sidebar-2',
//      'description'   => 'Right Sidebar',
//      'before_widget' => '<aside id="%1$s" class="widget %2$s">',
//      'after_widget'  => '</aside>',
//      'before_title'  => '<h4 class="widget-title">',
//      'after_title'   => '</h4>',
//  ) );
    register_sidebar( array(
        'name'          => 'Top Drawer',
        'id'            => 'drawer_top',
        'description'   => __( 'Drawer Top', 'thim' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => __( 'Offcanvas', 'thim' ),
        'id'            => 'offcanvas_sidebar',
        'description'   => 'Drawer Right',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => 'Menu Right',
        'id'            => 'menu_right',
        'description'   => __( 'Menu Right', 'thim' ),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget'  => '</li>',
        'before_title'  => '<h3>',
        'after_title'   => '</h3>',
    ) );
    register_sidebar( array(
        'name'          => 'Footer',
        'id'            => 'footer',
        'description'   => __( 'Footer Sidebar', 'thim' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s footer_widget">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => 'Copyright',
        'id'            => 'copyright',
        'description'   => __( 'Copyright', 'thim' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    register_sidebar( array(
        'name'          => __( 'Sidebar Shop', 'thim' ),
        'id'            => 'shop',
        'description'   => 'Shop Sidebar',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ) );
    if ( class_exists( 'LearnPress' ) ) {
        register_sidebar( array(
            'name'          => 'Top Sidebar Courses',
            'id'            => 'top_sidebar_courses',
            'description'   => __( 'Top Sidebar Courses', 'thim' ),
            'before_widget' => '',
            'after_widget'  => '',
            'before_title'  => '<h3>',
            'after_title'   => '</h3>',
        ) );
        register_sidebar( array(
            'name'          => 'Sidebar Courses',
            'id'            => 'sidebar_courses',
            'description'   => __( 'Sidebar Courses', 'thim' ),
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h4 class="widget-title">',
            'after_title'   => '</h4>',
        ) );
    }
}

之后使用操作

add_action('init','thim_widgets_inits_child');

相关内容

  • 没有找到相关文章

最新更新