WordPress.org

Support

Support » How-To and Troubleshooting » Change Widget Title h2 Wrapper to Span

Change Widget Title h2 Wrapper to Span

  • id eric

    @insidedesign

    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?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • id eric

    @insidedesign

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

    Moderator Samuel Wood (Otto)

    @otto42

    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') )
        register_sidebar(array(
            '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.

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change Widget Title h2 Wrapper to Span’ is closed to new replies.