Support » Fixing WordPress » wp_list_categories – Show empty cats but as plain text.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Andrew Bartel

    (@andrew-bartel)

    Why not just pass hide_empty => 1 in your arguments to wp_list_categories()? Is it really necessary to display a category that doesn’t have anything in it?

    If so, I’d say you’d probably need to finangle the css and disable the link with jquery.

    DLubofsky

    (@dlubofsky)

    It is necessary. Displaying a client list, and though we do not currently have work posted under some clients, we want to recognize them.

    Currently, we are manually adding css to change style, and js to disable link, each time we add a client. But, trying to make it less manual–has to be a less ‘hacky’ way of doing it.

    DLubofsky

    (@dlubofsky)

    Sounds pretty limiting to think it has to be done manually every time a client is added. Figured there had to be a better way.

    Andrew Bartel

    (@andrew-bartel)

    Ok, can you throw up a link to the site and I’ll take a look at the list?

    You could probably do some kind of conditional selector with js.

    DLubofsky

    (@dlubofsky)

    Working on this locally–it is a new version of out site. I will get it online this afternoon behind the scenes so you can take a peak. Thanks for taking the time to look at it–very generous of you. Will get you link shortly.

    vjpo

    (@vjpo)

    It is easy to do with get_categories() function and also possible by filtering wp_list_categories() html output through add_filter( 'wp_list_categories', 'custom_filter_function' ), but I can’t figure out now how to make it trough add_filter().

    Andrew Bartel

    (@andrew-bartel)

    I suppose you could do it with get_categories() but wouldn’t you end having to write a recursive function? That’s not particularly simple.

    I’ll be interested to see if there’s something unique about empty categories in the css or if it can be targeted specifically with jquery.

    vjpo

    (@vjpo)

    It is really easier with get_categories(). By default wp_list_categories() does not provide special classes for empty categories. JQuery can catch the link by (0) text, but, again, easier to use get_categories().

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘wp_list_categories – Show empty cats but as plain text.’ is closed to new replies.