Title: Remove Primary Sidebar from posts.
Last modified: August 21, 2016

---

# Remove Primary Sidebar from posts.

 *  Resolved [sarnava](https://wordpress.org/support/users/sarnava/)
 * (@sarnava)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/)
 * I want to remove the primary sidebar from ridizain theme. The Primary Sidebar’s
   Text is small and non-decorative. In place I want to use the Content Sidebar 
   but, when switching the post’s width becomes less and does not take the width
   of the primary sudebar(no-widgets).

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Theme Author [Brian Harris](https://wordpress.org/support/users/zgani/)
 * (@zgani)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654784)
 * Hello Sarnava,
 * That is not as simple as just removing the widgets. If you want to remove the
   left (Primary) sidebar then there’s some coding involved – a basic knowledge 
   of child theming, PHP and CSS is required.
 * What is your PHP/CSS code comfort level?
 * Zulf
 *  Thread Starter [sarnava](https://wordpress.org/support/users/sarnava/)
 * (@sarnava)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654787)
 * none for php and basic for css.
 *  Theme Author [Brian Harris](https://wordpress.org/support/users/zgani/)
 * (@zgani)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654796)
 * OK, if you’d like to hold on for a few days I’ll work an option in to the theme
   to remove the left sidebar. The new version for this won’t be available till 
   sometime next week/weekend though.
 * Regards,
    Zulf.
 * P.S: If you still want to give it a shot and code it yourself in a child theme
   then give me a shout and I’ll sort the CSS out for you. But do bare in mind that
   it is a bit involved and there may be some PHP adjustments required.
 *  Thread Starter [sarnava](https://wordpress.org/support/users/sarnava/)
 * (@sarnava)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654807)
 * If I replace the id or classes according to your theme in the following code 
   and create a child theme and paste this in the “sidebar.php”, Will it Work ?
 *     ```
       <?php global $theme; ?>
       <?php if ( !is_single() ) : ?>
       <div id="sidebar-primary">
   
           <?php
               if(!dynamic_sidebar('sidebar_primary')) {
                   /**
                   * The primary sidebar widget area. Manage the widgets from: wp-admin -> Appearance -> Widgets
                   */
                   $theme->hook('sidebar_primary');
               }
               $theme->hook("sidebar_primary_after");
           ?>
   
       </div><!-- #sidebar-primary -->
       <?php endif; ?>
   
       <div id="sidebar-secondary">
   
           <?php
               if(!dynamic_sidebar('sidebar_secondary')) {
                   /**
                   * The secondary sidebar widget area. Manage the widgets from: wp-admin -> Appearance -> Widgets
                   */
                   $theme->hook('sidebar_secondary');
               }
           ?>
   
       </div><!-- #sidebar-secondary -->
       ```
   
 *  Theme Author [Brian Harris](https://wordpress.org/support/users/zgani/)
 * (@zgani)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654832)
 * All that code will do is return an empty primary sidebar – plus you’ll get errors
   if you are not hooking to the right selector.
 * No need to complicate matters – just leave sidebar.php as it is and add the following
   CSS code to your child theme’s style.css
    `.site:before,#secondary{width:0;display:
   none;}.ie8 .site:before,.ie8 #secondary{width:0px;display:none;}.featured-content{
   padding-left:40px;}.site-content,.site-main .widecolumn{margin-left:40px;}.ie8.
   site-content,.ie8 .site-main .widecolumn{margin-left:40px;}`
 * `@media screen and (min-width: 1008px) {.search-box-wrapper{padding-left:368px;}}
   @media screen and (min-width: 1080px) {.search-box-wrapper,.featured-content{
   padding-left:368px;}}`
 * Then add the following code to your child theme’s functions.php
 *     ```
       function ridizain_remove_widgets(){
       	// Remove Primary sidebar from widget area.
       	unregister_sidebar( 'sidebar-1' );
       }
       add_action( 'widgets_init', 'ridizain_remove_widgets', 11 );
       ```
   
 * The CSS will remove the sidebar from the site and the function will remove the
   widget area from the Admin side.
 * Let me know how it goes.
 * Zulf
 *  Thread Starter [sarnava](https://wordpress.org/support/users/sarnava/)
 * (@sarnava)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654837)
 * Thank you sir, this worked. I am Very much grateful.
    Thank You.
 * Sarnava
 *  Theme Author [Brian Harris](https://wordpress.org/support/users/zgani/)
 * (@zgani)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654844)
 * You are most welcome 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Remove Primary Sidebar from posts.’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/ridizain/1.0.37/screenshot.png)
 * Ridizain
 * [Support Threads](https://wordpress.org/support/theme/ridizain/)
 * [Active Topics](https://wordpress.org/support/theme/ridizain/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/ridizain/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/ridizain/reviews/)

## Tags

 * [primary sidebar](https://wordpress.org/support/topic-tag/primary-sidebar/)

 * 7 replies
 * 2 participants
 * Last reply from: [Brian Harris](https://wordpress.org/support/users/zgani/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/remove-primary-sidebar-form-posts/#post-4654844)
 * Status: resolved