register_sidebar notice

时间:2016-05-20 作者:Sam Joseph

我已经手动更新了我的站点,现在我在前端和后端都收到了以下通知:

注意:register\\u侧栏调用不正确。未在参数数组中为“”设置id;主提要栏“;侧栏。默认为;侧栏-1“;。手动将id设置为;侧栏-1“;关闭此通知并保留现有侧栏内容。有关更多信息,请参阅WordPress中的调试。(此消息是在版本4.2.0中添加的。)

如何修复此问题?

2 个回复
SO网友:Nefro

查找文件的位置register_sidebar (必须位于主题文件夹或插件上)

将ID添加到侧栏

register_sidebar( array(
   \'name\' => __( \'Main Sidebar\', \'theme-slug\' ),

   \'id\' => \'change_me\',  // Add only this line

   \'description\' => __( \'Widgets in this area will be shown on all posts and pages.\', \'theme-slug\' ),
   \'before_widget\' => \'<li id="%1$s" class="widget %2$s">\',
   \'after_widget\'  => \'</li>\',
   \'before_title\'  => \'<h2 class="widgettitle">\',
   \'after_title\'   => \'</h2>\',
 ) );
或者您可以在中禁用通知wp-config.php

编辑WP_DEBUG 至false

define(\'WP_DEBUG\', false);

SO网友:cjbj

看起来你有一个非常古老的主题。您必须搜索functions.php 的文件register_sidebar 并确保$args 遵循格式mentioned in the codex.

相关推荐

如何从类插件显示ADMIN_NOTICES挂钩中的字符串

我试图在插件激活时在admin\\u notices hook中显示一条消息,在我的类中使用全局变量或静态变量($association\\u error)。我将变量值设置到register\\u activation\\u hook函数中:这一切都不起作用。我对wordpress开发和php非常陌生,如果这是一个简单的问题,请原谅。此外,我发现通知只包含设置到installMenu()中的字符串,而不包含设置到installDb()中的字符串。最后,我的通知未正确定位到通知区域中,但即使使用div的up