How to remove default sidebar/widgets in WordPress

In some WordPress themes, when you choose not to have any widgets/sidebar on a page, then default widgets/sidebars will be showed instead. But what if you really don’t want any sidebar on that page. Here I will show you how to permanently remove default sidebars – i.e. sidebars that are active when you have removed all widgets.

First you remove all widgets from the sidebar. You do this by going to Appearence -> Widgets and then delete all widgets. Then if widgets are still present on your page, this is probably because the theme have default widgets.

If you want to remove these, then go to Appearence -> Editor. Then find a file called sidebar.php or sidebar-default.php. Here you can often find a if-then sentence that controls what to do when there is no widgets. Then just remove the code inside this if-then sentence. The code inside could look like below:

<div class=”widget”>
<h3><?php _e( ‘Search’ ) ?></h3>
<?php get_search_form() ?>
</div>

<div class=”widget”>
<h3><?php _e( ‘Archives’ ) ?></h3>
<ul>
<?php wp_get_archives(‘type=monthly&show_post_count=1’); ?>
</ul>
</div>

<div class=”widget”>
<h3><?php _e( ‘Categories’ ) ?></h3>
<ul>
<?php
$cat_params = Array(
‘hide_empty’ => FALSE,
‘title_li’ => ”
);
if( strlen( trim( yiw_get_option( ‘blog_cats_exclude_2’ ) ) ) > 0 ){
$cat_params[‘exclude’] = trim( yiw_get_option( ‘blog_cats_exclude_2’ ) );
}
wp_list_categories( $cat_params );
?>
</ul>
</div>

<div class=”widget”>
<h3><?php _e( ‘Blogroll’ ) ?></h3>
<ul>
<?php wp_list_bookmarks( ‘title_li=&categorize=0’ ) ?>
</ul>
</div>

Then the widgets should be removed.

0 0 votes
Article Rating

Andreas Andersen

Forfatter og grundlægger af IT-blogger.dk, der har blogget om IT-emner siden 2012

Abonner
Giv besked ved
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x