widgets plugin oddity
-
I have an odd occurrence here. I’ve edited the functions.php file to change the LI tag listing of widgets to DIVs instead (per instructions for the plugin), by adding this to the functions.php file:
if ( function_exists('register_sidebars') )
register_sidebar(array(
'before_widget' => '<div id="%1$s" class="widget %2$s">', // Removes <li>
'after_widget' => '</div>', // Removes </li>
'before_title' => '<div class="title">', // Replaces <h2>
'after_title' => '</div>', // Replaces </h2>
));Basically, it changes the whole sidebar from being list items to each section/widget being placed within it’s own div – allowing for more styling flexibility. Which means that, when you “view source” for my page, the default layout for widgets goes from this:
<li id="archives"><h2>Archives</h2>
<ul>
<li><a href="#">Month 1</a></li>
<li><a href="#">Month 2</a></li>
</ul>…to this:
<div id="archives" class="widget widget_archives">
<div class="title">Archives</div>
<ul>
<li><a href="#">Month 1</a></li>
<li><a href="#">Month 2</a></li>
</ul>
</div>..which is exactly what I want.
However, for some unknown reason, the “blogroll” (or “Links”, as it’s known in the widgets adminsitrator area) will not convert to DIVs instead of LI’s. The LI and H2 tags (as shown in the first, default example) remain – no matter what I do. It’s only happening with the Links/Blogroll widget – none of the others have this issue.
Has anyone come across this problem before? It’s really annoying – it causes my page to not validate, because it won’t place a UL prior to the LI tag…and there’s no way to style it using CSS to remove the extra margins and padding that are placed there for the rest of the stuff that’s working properly.
It just doesn’t make sense as to why it’ll DIV out every single widget *except* for the Links/Blogroll. Just curious as to why it’s doing this, and if there’s any way of fixing it.
-
i’ve been grinding this axe for a while.
this is the code for the blogroll widget:
function widget_links($args) {
// This ONLY works with li/h2 sidebars.
get_links_list();
}
helpful, huh? kinda makes you wonder why they bothered writing an API at all.
this is my solution, see andy’s comment for its limitations. you’re welcome to put the widget inside your functions.php file. you may want to add
unregister_sidebar_widget ( Links );
to functions.php as well, to prevent accidents.Thanks hon! I knew eventually someone would come along and know what was going on 🙂
The topic ‘widgets plugin oddity’ is closed to new replies.