WordPress.org

Ready to get started?Download WordPress

Forums

<div></div> breaking the design if put in sidebar.php (3 posts)

  1. da_silva
    Member
    Posted 7 years ago #

    hi guys i have this problem: i want to list the childs of the currently browsed category and thus i've placed in the sidebar.php the usual

    <?php wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=2&hide_empty=0')
    ?>

    I also need to custom the background image in the list so i put the code in a div but it breaks the design. The code is:

    <div><?php wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=2&hide_empty=0') ?></div>

    I don't know what the problem is because this line, placed anywhere in the sidebar both in the default theme and mine-which i suspected to be to blame- breaks the layout.
    oh and the problem is only in IE browser, the others handle well the code, at least the error isn't seen at layout level.

  2. da_silva
    Member
    Posted 7 years ago #

    i got it, sorry for bodering, the whole problem was not placing the div in a <u> in the list. So it was my lack of knowledge in css, i didn't know this is wrong:
    <li>
    <div><?php wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=2&hide_empty=0') ?></div></div>
    </li>

    but i should have written like this:
    <li><ul>
    <div><?php wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=2&hide_empty=0') ?></div></div>
    </ul></li>

    I don't know for sure if it's correct but works. ;)

  3. KatGirl
    Member
    Posted 7 years ago #

    No, its not correct. When using <div> elements, you have to put
    <ul>, <li> inside the <div>

    It should be:
    <div>
    <ul>
    <?php wp_lists_cats(your specs here); ?>
    </ul>
    </div>

    wp_lists_cats generates a list of category links with <li> already embedded into the code.

    And it really is bad form to put <div> inside an <li> like you've done.

    Check your validation html

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags