WordPress.org

Ready to get started?Download WordPress

Forums

Change Widget Title h2 Wrapper to Span (4 posts)

  1. id eric
    Member
    Posted 5 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?

    Thanks

  2. id eric
    Member
    Posted 5 years ago #

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

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    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.

  4. printing4fun
    Member
    Posted 5 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