Title: Delete One Sidebar in diffrent category &#8211; Function.php ?
Last modified: August 19, 2016

---

# Delete One Sidebar in diffrent category – Function.php ?

 *  [marcinpl](https://wordpress.org/support/users/marcinpl/)
 * (@marcinpl)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/delete-one-sidebar-in-diffrent-category-functionphp/)
 * Hi
    I fight with this couple of days.
 * My site use theme Fervens c and there is no code in single page to determine 
   number of sidebars.
    Only one place when I can change it is Function.php:
 *     ```
       <?php
   
       if ( function_exists('register_sidebar') )
           register_sidebars(2, array(
               'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-all">',
               'after_widget' => '</div></div>',
               'before_title' => '<h3 class="widgettitle">',
               'after_title' => '</h3>',
           ));
       ```
   
 * I want delete one of sidebars in my category ID: 4106
    Now i use code:
 *     ```
       <?php
       $post = $wp_query->post;
       if ( in_category('4106') ) {
       include(TEMPLATEPATH . '/single2.php');
       } else {
       include(TEMPLATEPATH . '/single1.php');
       }
       ?>
       ```
   
 * So it check category and I use diffrent template for category ID: 4106 buy still
   I cant delete one of sidebars
 * help guys
    thx

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

 *  [Edward Caissie](https://wordpress.org/support/users/cais/)
 * (@cais)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/delete-one-sidebar-in-diffrent-category-functionphp/#post-1233677)
 * You will likely have code in your sidebar.php file that looks similar to the 
   following:
 *     ```
       <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(2)) : else : ?><?php endif; ?>
       ```
   
 * Just “wrap” that code section (or line) with something similar to this:
 *     ```
       <?php if (!in_category('4106')) : ?>
         <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(2)) : else : ?><?php endif; ?>
       <?php endif; ?>
       ```
   
 * I believe that will work for you … I did not see the theme you mentioned in the
   WP repo so I could not test directly.
 *  Thread Starter [marcinpl](https://wordpress.org/support/users/marcinpl/)
 * (@marcinpl)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/delete-one-sidebar-in-diffrent-category-functionphp/#post-1233686)
 * Thanks Cais – you helped me 😉
    But something wrong happend with sidebar on another
   pages. I used this:
 * <!–Start Dynamic Sidebar –>
    <?php if (!in_category(‘4106’)) : ?> <?php if (function_exists(‘
   dynamic_sidebar’) && dynamic_sidebar(2)) : else : ?><?php endif; ?>
 * but now category page it’s ok but in another pages, sidebar 2 copied to sidebar
   1 and I have to similar sidebars.
    ps. This code copied widget from sidebar 2(
   not htm from sidebar 2)
 *  Thread Starter [marcinpl](https://wordpress.org/support/users/marcinpl/)
 * (@marcinpl)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/delete-one-sidebar-in-diffrent-category-functionphp/#post-1233696)
 * Now it’s ok i wrote bad sidebar numer 😉
    thanks

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

The topic ‘Delete One Sidebar in diffrent category – Function.php ?’ is closed to
new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [marcinpl](https://wordpress.org/support/users/marcinpl/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/delete-one-sidebar-in-diffrent-category-functionphp/#post-1233696)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
