WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_cats ul before and after? (3 posts)

  1. vavroom
    Member
    Posted 8 years ago #

    Hello all,

    I've looked both here and on the Codex, and can't seem to find the answer I need. Of course I may have missed it, please don't hesitate to point me back to where I've missed the info (as if you would hesitate anyway!).

    In my Category.php page, I have

    <?php wp_list_cats('child_of='.$cat);?>

    before the Loop.

    This displays children items of the current category in a unordered list.

    The problem is that in order for it to work, I had to hardcode

    <ul> before the call, and </ul>
    after the call...

    This isn't a problem per se, until you reach a category that doesn't have children items. At that point, you end up with an empty

    <ul></ul>
    , which breaks validation and plays havock with the site.

    There doesn't appear to be a before/after parameter for that tag.

    Any idea on how to best load the ul tag only if there are list items to be displayed?

    Thanks for any and all information.

  2. vavroom
    Member
    Posted 8 years ago #

    Sorry for bumping, but has no one any idea on this??????

  3. vavroom
    Member
    Posted 7 years ago #

    Another bump...

    Anyone? Anyone at all?

    I've been trying all variety of trying "if" statements. But I can't seem to find the right "if", or the right phrasing.

    I've tried if "empty", or "==Null", or any number of things. Doesn't work.

    I suspect it's an easy thing, I can't imagine I'm the first one to run into this problem. I mean... wp_list_cats loading in
    <li> tags is fine, but one has to wrap that in
    <ul>. If there's no children to display, then you have empty <ul> That doesn't work...

    What am I missing?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.