One of our users asked us if it was possible to remove inactive widgets in WordPress. Once you have tried out different themes and played along with many plugins, you will notice that a number of inactive widgets would start accumulating in your inactive widget area. When you stop using a widget or change a theme, your widgets are moved to inactive widgets area. This is done primarily to make sure that you don’t lose your widgets when changing WordPress themes. Removing inactive widgets manually takes some time because you have to click on each widget to open the drop down box containing the link to delete that widget. In this article we will show you how to remove inactive widgets in WordPress.
我们的一位用户问我们是否可以删除WordPress中的非活动窗口小部件。 一旦尝试了不同的主题并与许多插件一起使用,您将注意到许多不活动的窗口小部件将开始在您不活动的窗口小部件区域中累积。 当您停止使用窗口小部件或更改主题时,您的窗口小部件将移动到非活动窗口小部件区域。 这样做主要是为了确保您在更改WordPress主题时不会丢失小部件。 手动删除不活动的窗口小部件会花费一些时间,因为您必须单击每个窗口小部件以打开包含删除该窗口小部件的链接的下拉框。 在本文中,我们将向您展示如何在WordPress中删除无效的窗口小部件。
First thing you need to do is install and activate the Remove Inactive Widgets plugin. After activating the plugin, go to Appearance » Widgets. Inside the inactive widgets box you will see a button labeled Remove Inactive Widgets. Pressing the button will remove all your inactive widgets without even reloading the page.
您需要做的第一件事是安装并激活Remove Inactive Widgets插件。 激活插件后,转到外观»小部件 。 在非活动窗口小部件框内,您会看到一个标记为删除非活动窗口小部件的按钮。 按下按钮将删除您所有不活动的窗口小部件,甚至无需重新加载页面。
![Removing inactive widgets in WordPress Removing inactive widgets in WordPress](https://i-blog.csdnimg.cn/blog_migrate/d38499375534ab3e25cf1c72c46c9903.png)
For those who don’t like the plugin method, you can simply paste the following code in your theme’s functions.php file. All you have to do after that is reload the widgets page, and all your inactive widgets will be gone. Don’t forget to remove this code once you are done.
对于那些不喜欢plugin方法的用户,您只需将以下代码粘贴到主题的functions.php文件中即可。 之后,您要做的就是重新加载小部件页面,所有不活动的小部件都将消失。 完成后,不要忘记删除此代码 。
$widgets = get_option('sidebars_widgets');
$widgets['wp_inactive_widgets'] = array();
update_option('sidebars_widgets', $widgets);
We hope that this article helped you in removing inactive widgets in WordPress. If you have any questions related to this, then feel free to leave a comment below. For all other questions, please ask us on twitter (@wpbeginner).
我们希望本文能帮助您删除WordPress中的非活动窗口小部件。 如果您对此有任何疑问,请随时在下面发表评论。 对于所有其他问题,请在Twitter(@wpbeginner)上向我们提问 。
翻译自: https://www.wpbeginner.com/plugins/how-to-remove-the-inactive-widgets-in-wordpress/