Title: Widget problem
Last modified: August 19, 2016

---

# Widget problem

 *  [sensifreak](https://wordpress.org/support/users/sensifreak/)
 * (@sensifreak)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/)
 * Hi,
    I want that my sidebar is supporting widgets. This is the code of the html
   markup:
 *     ```
       <div class="sidebar-head"><h3></h3></div>
       <div class="sidebar-content"></div>
       <div class="sidebar-footer"></div>
       ```
   
 * so i tired using the tutorials and came to this php code:
 *     ```
       <?php
       if ( function_exists('register_sidebar') )
       register_sidebar(array(
       'before_widget' => '<div class="sidebar-content">',
       'after_widget' => ' </div>
           <div class="sidebar-footer"></div>',
       'before_title' => '<div class="sidebar-head">
       <h2>',
       'after_title' => '</h2></div>',
       ));
       ?>
       ```
   
 * But it doesnt work what is wrong?
    please help me

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

 *  [wp_guy](https://wordpress.org/support/users/wp_guy/)
 * (@wp_guy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761080)
 * The code in your sidebar should look something like:
 *     ```
       <div class="sidebar-head"><h3></h3></div>
       <ul class="sidebar-content">
       <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
           <!-- What happens if you don't have the widgets functionality. Static widgets for example. -->
       <?php endif; ?>
       </ul>
       <div class="sidebar-footer"></div>
       ```
   
 * Then, in the functions.php file:
 *     ```
       if ( function_exists('register_sidebar') )
           register_sidebar(array(
               'before_widget' => '<li id="%1$s" class="widget %2$s">',
               'after_widget' => '</li>',
               'before_title' => '<h2 class="widgettitle">',
               'after_title' => '</h2>',
           ));
       ```
   
 * And that should do it.
 *  Thread Starter [sensifreak](https://wordpress.org/support/users/sensifreak/)
 * (@sensifreak)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761081)
 * but thats html code is one element of the sidebar.
    every widget should look 
   like this. you know what i mean?
 *  [wp_guy](https://wordpress.org/support/users/wp_guy/)
 * (@wp_guy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761084)
 * oh… I thought that whas the whole sidebar… Hmmm… Since the widget title gets 
   echoed inside the widget and not outside as in your code…
 *     ```
       if ( function_exists('register_sidebar') )
           register_sidebar(array(
               'before_widget' => '<div class="sidebar-head">',
               'after_widget' => '</div>
       <div class="sidebar-footer"></div>',
               'before_title' => '<h3>',
               'after_title' => '</h3></div>
       <div class="sidebar-content">',
           ));
       ```
   
 * But you’re probably going to have problems with widgets that don’t have a title,
   like the search widget.
 *  Thread Starter [sensifreak](https://wordpress.org/support/users/sensifreak/)
 * (@sensifreak)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761089)
 * mhm damn it dowsnt work. Do you have an e-mail so i can show you the link to 
   the theme
    greetz
 *  [wp_guy](https://wordpress.org/support/users/wp_guy/)
 * (@wp_guy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761090)
 * [http://wpguy.com/contact](http://wpguy.com/contact) 😉 I don’t want to get spammed
   by everyone 😀
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761095)
 * *spams the contact form*
 *  [wp_guy](https://wordpress.org/support/users/wp_guy/)
 * (@wp_guy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761101)
 * lol >:-O
 *  [stonedhippy2001](https://wordpress.org/support/users/stonedhippy2001/)
 * (@stonedhippy2001)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761352)
 * I have a similar question to sensifreak. I can add widgets to my page at the 
   moment using the dashboard but instead of adding them to my normal sidebar somewhere
   like I want it puts them in instead/over my sidebar.
 * The code for my sidebar is
 * >  <div id=”sidebar”>
    -  <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?
      >
       <?php wp_list_pages(‘title_li=<h2>Pages</h2>’ ); ?>
    - <h2>Archives</h2>
 *  -  <?php wp_get_archives(‘type=monthly’); ?>
 *  -  <h2>Calendar</h2>
       <?php get_calendar(1); ?>
    - <h2>Categories</h2>
 *  -  <?php wp_list_cats(‘sort_column=name&optioncount=0&hide_empty=0&all=1’); ?
      >
 *  <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
    <?php
   get_links_list(); ?>
 *  <?php } ?>
 *  <?php endif; ?>
    </div>
 * My functions.php is as follows too:
 * >  <?php
   >  if ( function_exists(‘register_sidebar’) ) register_sidebar(); ?>
 * I’ve searched all the themes code for mentions of widgets but haven’t been able
   to find anything and don’t even know where to start playing around with them 
   so any help would be appreciated!
 *  [wp_guy](https://wordpress.org/support/users/wp_guy/)
 * (@wp_guy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761355)
 * Indeed… what the code in your sidebar.php file does is: If the widgets feature
   is available and there are widgets, then show these widgets, if not, then show
   the regular sidebar.
 * If you want your regular sidebar AND the widgets then you might want to change
   your code to something like:
 *     ```
       <div id="sidebar">
   
       <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
           <!-- What happens if there are no widgets -->
       <?php endif; ?>
   
       <?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?>
   
       <h2>Archives</h2>
       <?php wp_get_archives('type=monthly'); ?>
   
       <h2>Calendar</h2>
       <?php get_calendar(1); ?>
   
       <h2>Categories</h2>
       <?php wp_list_cats('sort_column=name&optioncount=0&hide_empty=0&all=1'); ?>
   
       <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
       <?php get_links_list(); ?>
   
       <?php } ?>
   
       </div>
       ```
   
 *  [stoned-hippy](https://wordpress.org/support/users/stoned-hippy/)
 * (@stoned-hippy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761357)
 * Aahh, thank you very much. I didn’t realise it worked like that, maybe i’ll try
   to just use widgets so.
 * Thanks again,
    S.h.2001

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

The topic ‘Widget problem’ is closed to new replies.

## Tags

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

 * 10 replies
 * 5 participants
 * Last reply from: [stoned-hippy](https://wordpress.org/support/users/stoned-hippy/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/widget-problem-3/#post-761357)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
