2

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">
2

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>',
1

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.

0

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.

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.