我希望能够删除我的WordPress
网站中添加的小部件
通过functions.php
就像使网站整洁而没有任何插件。
我找到了这段代码
// Delete All Existing Widgets
$sidebar_widgets = wp_get_sidebars_widgets();
foreach($sidebar_widgets['footer_first'] as $i => $widget) {
unset($sidebars_widgets['footer_first'][$i]);
}
wp_set_sidebars_widgets($sidebars_widgets);
但是似乎不正确。
我在整个Internet上进行了搜索,但是我所得到的只是如何unRegister
我已经熟悉的整个小部件。
,我只想从侧边栏部分删除它。
答案 0 :(得分:0)
使用下面的代码希望隐藏侧边栏
function disable_sidebar_custom( $sidebars_data )
{
if($sidebars_data['footer_first'] !=''){
$sidebars_data['footer_first'] = false;
}
return $sidebars_data;
}
add_filter( 'sidebars_widgets', 'disable_sidebar_custom' );