• Resolved thanksforthehelp

    (@thanksforthehelp)


    I want to set my categories widget to display the category selection dropdown, but there’s no <li> tag before the <select> so my css isn’t styling it like it should.

    I know to edit it is in widgets.php but I can’t find the html code to add the <li>' tags before the<select>` tag.

    Any help would be appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Instead of modifying the widget code, why not fix your CSS to style it correctly instead?

    Thread Starter thanksforthehelp

    (@thanksforthehelp)

    Thanks for the response Otto42. To answer your question:

    I’ve coded it so that the <li> adds borders. I want to keep away from using background images to display the borders. The module blocks have round corners they need to expand to accommodate the content. As it is now, I have the surrounding <h2> displaying top round border, child <li> displaying the borders, and the main <li> that encompasses the header and content displaying the bottom round border.

    The way it is now, there is no child <li> or any block element surrounding the <select> tags. So I need to add them.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    I get what you’re saying, but that doesn’t really make any sense. I mean, in that case it sounds like your theme is broken instead.

    See, every widget will have the same surrounding items, including the categories widget. So adding an extra LI in there doesn’t really make any sense. All sidebar items look the same, only their content changes. That’s the whole point.

    Give us a link to your site so we can see what you’re doing. Also give us the first part of the theme’s functions.php, so we can see the call to register_sidebar.

    Thread Starter thanksforthehelp

    (@thanksforthehelp)

    https://tinyurl.com/35ebxq

    The “categories 3” block is on the 3rd column below the search.

    WP does generate the <li> child element, my mistake, I actually need to add another <ul><li> and not just a <li>. The way wp widgets.php has it now, the tree looks like <ul><li><h2> and then the content.

    For this specific block the tree is <ul><li><h2><select>. I need it to be <ul><li><h2><ul><li><select>.

    Thanks.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Hmmm.. Well, okay.

    Find this in the widgets.php file:

    if ( $d ) {
    wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category'));
    ?>

    Change it to this:

    if ( $d ) {
    echo '<ul><li>';
    wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category'));
    echo '</li></ul>';
    ?>
    Thread Starter thanksforthehelp

    (@thanksforthehelp)

    Works like a charm. Thanks Otto42. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Style wordpress categories widget’ is closed to new replies.