WordPress.org

Forums

wrap categories in h2 tag (4 posts)

  1. andrewkro
    Member
    Posted 5 years ago #

    Hi,

    My client wants to put categories list in h2 tags. Right now the categories are displayed using the default wp wigdet. What should I modify to surround them with <h2> tags?

    Any help will be deeply appreciated.

    Andrew

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    By default, the widgets use an <h2> tag. Check the theme's functions.php file.

  3. andrewkro
    Member
    Posted 5 years ago #

    Thanks do much for the tip! One quick clarification:

    In the functions.php I currently have

    register_sidebar(array(
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h5 class="widgettitle">',
            'after_title' => '</h5>',

    I need to wrap individual list items in <h2> tags, so the list would look like this:

    <ul>
    <li><h2>Category1</h2></li>
    <li><h2>Category2</h2></li>
    <li><h2>Category3</h2></li>
    </ul>

    What code do I need to add?

    Thanks again for the help.

  4. esmi
    Forum Moderator
    Posted 5 years ago #

    Try replacing the function.php code above with:

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

Topic Closed

This topic has been closed to new replies.

About this Topic