如何删除WordPress中的非活动小部件

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

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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值