[wp-hackers] wp_list_categories()

DD32 wordpress at dd32.id.au
Sun Dec 28 01:42:02 GMT 2008

First up, Absolute URL's: They're all generated by get_permalink() Theres a
filter on that i believe, So if you wish to remove the domain from such
links, you can easily do so

Secondly, Nested lists, The <ul> -has- to be within a <li> for it to be
valid HTML, It can either be <li><a>...</a><ul class="children" or
<li><a>..</a></li><li><ul class=children> but that causes issues with
numbered lists or for that matter, any list which has any form of bullet or
marker before it..

you could use li:hover{} in combination with li:hover ul{} to work around it
I guess,

Also, A CSS class such as cat-child-xxxxx would be rather pointless, It
describes the content, but does nothing to arrange it visually, and since
it'll be different in every case, its near impossible to rely on it.

I really cant see a reason why single vs multi line li's is going to make a
difference to backgrounds either.. It nearly sounds like you're assuming
that the HTML is different than from what it is or something.. i'm not

2008/12/28 Mike Schinkel <mikeschinkel at gmail.com>

> Hi all:
> I've been working on a category plugin for a client.  I would have thought
> something like it would exist but couldn't find one so I'm building it
> myself.
> However, I've run into several annoying issues with using *
> wp_list_categories()* which I'd far prefer to use than to code all the SQL
> myself (not because I don't have the skills but because I'd rather use a
> core WP function for future compatibility.) Let me provide a output snippet
> from the site I'm working on (I removed titles from <a> tags and removed
> the
> domain from the <a> @href attribute to make it easier to understand the
> HTML, and I reformatted):
> ......[snip].....
> The first issue is with how it organizes it's HTML.  Although I would
> logically prefer having the <li> elements enclose <ul ="children"> elements
> it makes it hard to clumsy to target with CSS and jQuery (i.e. using
> "li:hover" ends up highlighting everything, including children) and it
> makes
> it hard to appropriate place background images using "background:url(...)"
> Neither "background-position:left top;" nor "background-position:left
> center;" work well for icons that otherwise work well on a single-line
> <li>.
> So here's what I'd like to see instead:
> ......[snip].....

Of course that could cause all kinds of backward compatibility issues should
> it should be triggered by a new parameter, maybe "*li_contains_ul*?"
> In addition, this would almost require that the <ul> be given a class that
> identifies the parent category ID, maybe "*cat-child-{nnn}*", like so:
> ......[snip].....
> I don't see any backward compatibility issues with adding that class so I
> wouldn't see a need to enable with a parameter, even with old style markup
> so I would just add in.
> On another note, is there any reason to have absolute links and include the
> full domain in the <a> href?  For a long list of categories it adds
> unneccesary output.  What about an "*omit_domain*" parameter?
> The last two items are 1.) it would really be nice to be able to get the
> list of categories as an array as opposed to as HTML (parameter
> "*as_array*?"),
> and 2.) why is there no equivalent wp_list_tags()?
> I'd be happy to do the work to add these options assuming you guys agree
> with the concept(s) and would recommend it for inclusion in 2.8.   Let me
> know...

More information about the wp-hackers mailing list