Title: Changing widgets in functions.php
Last modified: August 21, 2016

---

# Changing widgets in functions.php

 *  Resolved [markroth](https://wordpress.org/support/users/markroth/)
 * (@markroth)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/)
 * I want to change the _widget-title_ from **<h1** to **<h3** in my SemPress child
   theme.
 * I know I can do this in my child theme’s _functions.php_ by changing the following
   code from the parent theme’s _functions.php_:
 *     ```
       function sempress_widgets_init() {
         register_sidebar( array(
           'name' => __( 'Sidebar 1', 'sempress' ),
           'id' => 'sidebar-1',
           'before_widget' => '<section id="%1$s" class="widget %2$s">',
           'after_widget' => "</section>",
           'before_title' => '<h1 class="widget-title">',
           'after_title' => '</h1>',
         ) );
   
         register_sidebar( array(
           'name' => __( 'Sidebar 2', 'sempress' ),
           'id' => 'sidebar-2',
           'description' => __( 'An optional second sidebar area', 'sempress' ),
           'before_widget' => '<section id="%1$s" class="widget %2$s">',
           'after_widget' => "</section>",
           'before_title' => '<h1 class="widget-title">',
           'after_title' => '</h1>',
         ) );
       }
       add_action( 'init', 'sempress_widgets_init' );
       ```
   
 * Despite a lot of research and some tries, I haven’t been able to get something
   workable. I gather I need to use _remove\_action_ somehow. But nothing I’ve read
   has penetrated this thick skull far enough to produce something usable.
 * Could somebody please tell me exactly what my code needs to be?
 * **Thank you!**

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

 *  [mido116](https://wordpress.org/support/users/mido116/)
 * (@mido116)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293910)
 * Hi,
 * You can just change the html markup on the two sidebars:
    So change this part
   of the code:
 *     ```
       'before_title' => '<h1 class="widget-title">',
          'after_title' => '</h1>',
       ```
   
 * To
 *     ```
       'before_title' => '<h3 class="widget-title">',
         'after_title' => '</h3>',
       ```
   
 * I hope this answers your question.
    The Best Of Luck
 *  Thread Starter [markroth](https://wordpress.org/support/users/markroth/)
 * (@markroth)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293936)
 * Thanks for the reply, mido116.
 * Alas, that doesn’t do anything for the dynamic sidebars.
 * That’s what I’m wanting to change.
 *  [mido116](https://wordpress.org/support/users/mido116/)
 * (@mido116)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293940)
 * Well, I am not really sure what changes you are looking for on the sidebar, but
   that will change the widget tile from <h1>Tile</h1> to <h3>Title</h3>.
    You can
   inspect the widget title in your browser to if the change actually happened. 
   maybe you are not seeing any changes because the tags h1 nad h3 has the same 
   style in your theme.
 *  Thread Starter [markroth](https://wordpress.org/support/users/markroth/)
 * (@markroth)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293943)
 * The code in my opening post is what generates the _dynamic_ sidebar.
 * Your suggestion changes the _static_ sidebar; it does nothing for the dynamic
   stuff.
 * By the way, I noticed a few minutes ago over on [github](https://github.com/pfefferle/SemPress/blob/master/sempress/functions.php)
   that [pfefferle](http://wordpress.org/support/profile/pfefferle) has in mind 
   to change the SemPress sidebar header tags to <h3> in version 1.4.5, so that’s
   great!
 * But for the sake of understanding WP and php a little better, I’d still like 
   to know how to code up a child theme’s _functions.php_ as I asked in my opening
   post.
 * And thanks again, **mido**, for engaging my inquiry!
 *  [mido116](https://wordpress.org/support/users/mido116/)
 * (@mido116)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293948)
 * If you take a look at the line 269 on [pfefferle’s code](https://github.com/pfefferle/SemPress/blob/master/sempress/functions.php)
   you’ll see that he did exactly what i said, he changed h1 to h3. But still I 
   am not really sure what you mean by static and dynamic sidebar.
    And as for knowing
   how to code up a child theme’s functions.php you can refer to it [here](http://codex.wordpress.org/Child_Themes)
   where they explain exactly how you can create your own functions.php on your 
   child theme.
 * The best of Luck
 *  Thread Starter [markroth](https://wordpress.org/support/users/markroth/)
 * (@markroth)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293951)
 * I’m sorry, mido116. I thought you were telling me in your first comment that 
   I should make those changes in _sidebar.php_. My apologies for misunderstanding.
 * So, now that I’m on the same page with you, yes, I know that’s what needs to 
   change. But like I said in my opening post, I just can’t get how to implement
   _remove\_action_ (or whatever it takes in the child theme).
 * You gave me a link in the Codex, but I’d already been there repeatedly. And I’ve
   read plenty of other stuff. Like I said in my opening, “nothing I’ve read has
   penetrated this thick skull far enough to produce something usable.” 🙁
 *  Thread Starter [markroth](https://wordpress.org/support/users/markroth/)
 * (@markroth)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293955)
 * OK, I think I got it now (through more trial and error):
 *     ```
       // CHANGES WIDGET HEADINGS TO H3 (INSTEAD OF H1)
   
       add_action( 'after_setup_theme', 'remove_parent_theme_features', 10 );
   
       function remove_parent_theme_features() {
       	remove_action( 'init', 'sempress_widgets_init' );
       	add_action( 'init', 'ph_sempress_widgets_init' );
       }
   
       function ph_sempress_widgets_init() {
         register_sidebar( array(
           'name' => __( 'Sidebar 1', 'sempress' ),
           'id' => 'sidebar-1',
           'before_widget' => '<section id="%1$s" class="widget %2$s">',
           'after_widget' => "</section>",
           'before_title' => '<h3 class="widget-title">',
           'after_title' => '</h3>',
         ) );
   
         register_sidebar( array(
           'name' => __( 'Sidebar 2', 'sempress' ),
           'id' => 'sidebar-2',
           'description' => __( 'An optional second sidebar area', 'sempress' ),
           'before_widget' => '<section id="%1$s" class="widget %2$s">',
           'after_widget' => "</section>",
           'before_title' => '<h3 class="widget-title">',
           'after_title' => '</h3>',
         ) );
       }
       ```
   
 * It works for me. Is it proper coding, though?
 * Here’s where I have it implemented: [Panting Hart](http://www.eaf.net/pantinghart/).
 *  [mido116](https://wordpress.org/support/users/mido116/)
 * (@mido116)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293956)
 * Yes it is clean code, I can see that you removed the action of the parent theme
   and replaced it with your action. Personally I would do it like that.

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

The topic ‘Changing widgets in functions.php’ is closed to new replies.

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

## Tags

 * [child theme](https://wordpress.org/support/topic-tag/child-theme/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * 8 replies
 * 2 participants
 * Last reply from: [mido116](https://wordpress.org/support/users/mido116/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/changing-widgets-in-functionsphp/#post-4293956)
 * Status: resolved