8

I've got a basic text widget and, outside the standard <div class="textwidget"> wrapper there is a <li id="text-5" class="widget widget_text"> (which I have not added when creating the sidebar in functions.php or added when adding a text widget from the dashboard).

i.e. the full code looks like this:

<li id="text-5" class="widget widget_text">
  <div class="textwidget">
    <my content>
  </div>
</li>

I'm at a loss where this li comes from. Any idea why and how I can get rid of it?

1
  • can you show you sidebar.php and the function you're using in your functions.php to create the widget areas please?
    – bigmadwolf
    Sep 17, 2015 at 22:35

3 Answers 3

2

I think WordPress widgets create li tags on default. If you want the bullet points removed you could fix that with a css approach.

.widget li {
  list-style: none;
}
1
  • +1 for the li tags on default. That was throwing me. After I removed them I didn't need the CSS.
    – Snowcrash
    Sep 18, 2015 at 13:30
9

This seems to occur when you leave out 'before_widget' and 'after_widget' in the array when you register your sidebar/widget. I had the same problem and fixed it by leaving them blank.

register_sidebar( 
    array(  
        'name' => 'Footer Widget',
        'id' => 'footer-widget-1',
        'class' => 'footer-widget',
        'description' => 'Footer widget',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
    ) 
);
1
  • 1
    Just logged in to upvote your post :) After 1 hour of banging my head on the wall, I stumbled here! Thanks this helped. Sep 18, 2020 at 14:41
0

There is a truble with your wordpress theme in file "functions.php" there is a function for creating sidebar, there you have to add this code

    'before_widget' => '<aside id="%1$s" class="di-widget %2$s">',
    'after_widget'  => '</aside>',
    'before_title'  => '<h3 class="di-widget-title">',
    'after_title'   => '</h3>',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.