Change Widget Title h2 Wrapper to Span (4 posts)

  1. id eric
    Posted 7 years ago #

    Hello, I am trying to figure out how I change the h2 tags that surround a widget title into a span tag. I understand that this is not a theme issue, but a modification within wordpress itself. correct?

    So, for example, when I add a text widget with a title of "Fun Widget" - I do not want the h2 tag to surround my widget title. Rather, I would like a span tag with a class instead. Where do I do this?


  2. id eric
    Posted 7 years ago #

    Figured it out. Edit widgets.php in the wp-includes folder. Line 56 and 57

  3. Actually, you should have edited the theme, not the widgets.php file.

    In the theme's functions.php file, there's a call that sets up the sidebars, which looks similar to this:

    if ( function_exists('register_sidebar') )
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',

    You can change the before and after title bits there to change the H2 into whatever you want.

  4. printing4fun
    Posted 7 years ago #

    Tried the change in functions.php but simply couldn't get it to work so I edited widgets.php. That worked fine but now I have to remember the change every time I upgrade. At least I now have <h4> tags. Thanks Insidedesign!

Topic Closed

This topic has been closed to new replies.

About this Topic