• If you’re tired of messing with CSS to get your lists to look right (since WP renders everything as lists), here’s a way to get rid of them. There is an alternate list-free tag (or parameter) for each WP function that uses lists. Make these substitutions and manually delete the UL and LI markup from your index.php, and your bullet- and indent-problems will go away. Here’s what I did:
    I modified wp_list_cats() by adding the parameter list=0, like this: wp_list_cats(‘list=0’)
    I used get_archives() with parameters specifying BR tags instead of LI tags
    I used get_links() for each link category I wanted to display, instead of get_links_list()
    I manually deleted all the other UL and LI tags in the index.php file.
    Now that I’ve told you the important part, I’ll rant a little bit about the use of lists in WP, which in my book is excessive. I can think of no reason to force users (except those who can figure out how to get around it) to use lists for everything. It’s unduly complicated, because unless you use the default template, the lists are going to give you headaches. For example, I like to use a DIV to control the gray boxes in the sidebars. However, this is problematic with list items, because you aren’t supposed to have DIVs within list elements in XHTML. It can be done, but it won’t validate, and it’s messy.
    There are some things that should be rendered as lists, granted. I cannot think of a single reason, though, that you should render something as a list unless you want it to have bullets or be indented. When you want neither, making a list just complicates things. Yes, CSS can handle it, but that’s not a good enough reason.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thanks for posting this. Personally I disagree with you – AFAIK semantic markup means a bunch of links should be rendered as a list because it, well, IS a list – but there are many different ways to WP nirvana, choose yours and be happy 🙂

    Zadu is right…pick a path up the mountain and enjoy the view! What you do with your site, justin, is what makes it unique.
    Just remember to have fun doing it, because in the end, that’s what really matters.

    by the way, if you want a “div” inside a block element (like p, li, whatnot) you can use span – that validates just fine.

    Thread Starter justinbaeder

    (@justinbaeder)

    Zadu – On further reflection, I do like the fact that individual lists like the archives are rendered as lists. That makes sense, since it is list data. If everything were made into separate lists, that would be great.
    What I don’t like is having the entire sidebar rendered as one huge nested list, because that means you can’t have any block-level elements in your sidebar. Span works for some things, but you don’t get consistent widths with it. For example, in my sidebar, I have a CSS class called “sidetitle” that I use as a heading. It has a gray background and a border. If I make this a span instead of a div, they all come out different widths, which looks terrible.
    It also means you need five or six CSS tricks if you don’t want the sidebar to appear nested, since the lists occur at various nesting levels (e.g. the get_links() feature, which nests the links under the categories you select).

    I don’t think it would do any harm to agree that lists can seem alarming to people when they first encounter them in this way but they really are very cool. The degree of control we get over them is awesome. What in fairness it does require is a bit more CSS knowledge to really feel comfortable. In time though hopefully you will just love those lists. Everything you mention specifically in your post can easily be adjusted in the CSS alone. Good luck 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Getting Rid of Lists’ is closed to new replies.