Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a normal textbox widget that I am using in certain sidebars. The text widget generates a div within a ul. Is there anyway to make the widget generate another ul li instead?

<ul><h3>Heading</h3>            <div class="textwidget">
share|improve this question
add comment

3 Answers

check your sidebar.php and functions.php of the theme, the sidebar define the markup outside the widget; the function register_sidebar() defines the markup before content of the widgets; this markup you must change. See the codex for this function: codex register_sidebar()

Edit

Specifically, you need to look at the before_widget and after_widget parameters of the register_sidebar() arguments array.

If the register_sidebar() call looks like this:

register_sidebar(array( // Right Column widget area
    'name'=>'Sidebar Right',
    'id'=>'sidebar-right',
    'description' => 'Right-column, half-width sidebar in three-column layout',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<div class="title">',
    'after_title' => '</div>',
));

Then change it to this:

register_sidebar(array( // Right Column widget area
    'name'=>'Sidebar Right',
    'id'=>'sidebar-right',
    'description' => 'Right-column, half-width sidebar in three-column layout',
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<div class="title">',
    'after_title' => '</div>',
));

Specifically, you're changing this:

    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',

To this:

    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
share|improve this answer
add comment

You can unregister the default widget:

unregister_widget( 'WP_Widget_Text' );

Then register your own with custom markup...

http://codex.wordpress.org/Widgets_API

http://azuliadesigns.com/create-wordpress-widgets/


Or you can use Javascript and just tell it to adjust the HTML after the document finishes loading.


Or you can see if nesting your desired code completely within the current markup and just styling around the existing markup. You can remove any negative side effects it is giving you with CSS.

share|improve this answer
add comment

Use the wordpress default text widget. Its named "Text" in your widget area. You can add unlimited text widget in your sidebar. Each text widget creates new ul li. I hope you get what i mean.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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