WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_cats() children display problem (14 posts)

  1. ph33rful
    Member
    Posted 8 years ago #

    I know this has been posted about before, in this forum, and elsewhere, but I can't get it to work. All I want to do is display the top-level categories: meaning I don't want any sub-categories, so, I would use this code:

    <?php
    wp_listcats('children=0');
    ?>

    It should work, right?

    Edit: using latest release (1.5) of WP, hosted on apache, running on Ubuntu (linux)

  2. ColdForged
    Member
    Posted 8 years ago #

    Yes, with the caveat that you misspelled wp_list_cats() in your example.

  3. ph33rful
    Member
    Posted 8 years ago #

    please excuse that, a simple typo, rest assured that i did not misspell it within my code.

    also, that i did not mean to place this post within requests and feedback, i noticed that when after i placed it, and do not know how to get it moved.

  4. Lorelle
    Member
    Posted 8 years ago #

    That's okay. Unless you are a sysop, you will never get it moved.

    Information on this tag is found here with examples of how to set the children for the tag. One of those examples is as follows:

    <?php wp_list_cats('sort_column=id&child_of=8'); ?>

    Which sets the list to sort by ID and show only the children of category 8. If you do not want to show the children at all:

    <?php wp_list_cats('sort_column=id&children=0'); ?>

    If this is not working, check that you have put a ZERO and not an OH in the code, since this is actually a common boo boo. If this is close to what you used, then try retyping it and make sure you Refresh your screen completely to see the change take affect, if it does. If it doesn't, come on back and we'll take a better look.

  5. ph33rful
    Member
    Posted 8 years ago #

    The codex was where I went in the first place, I in fact used a little bit of there code to assure myself that I wasn't doing anything wrong, apparently, I still am.

    Both the code you supplied, and the codex, won't stop children from displaying. I even created a child of a child, just to see if that would work: it didn't.

    So far, no matter what I've done, I can't get children to *not* display.

  6. Root
    Member
    Posted 8 years ago #

    Many people are unaware that there are two generations of WP tags in use - they often appear in parallel. In this case the new one is list cats (no wp prefix).
    You may find it has the functionality you need and is more robust. The problem is that many theme designers just reach for any old thing. On the codex as per usual.

  7. ph33rful
    Member
    Posted 8 years ago #

    damn, good look. works fine. I knew it (list_cats()) existed, and I had tried it, but got lost in setting *all* the variables to get to the one i needed.

    the question is still there though: why would they share names, but not functionality? the codex says wp_list_cats can display only top-levels, but the code can't.

    or can it? and there's some black-magic voodoo i have to use to get it working?

    Thanks for the help, people :)

  8. Root
    Member
    Posted 8 years ago #

    Because AFAIK one has a bug in it and one does not.

  9. ph33rful
    Member
    Posted 8 years ago #

    thanks for the help, buddy.

  10. Root
    Member
    Posted 8 years ago #

    You are welcome.

  11. crowspeaker
    Member
    Posted 8 years ago #

    I can't find a way in either list_cats() or wp_list_cats() to give a 'before' or 'after' paramet. I'd like to set up the category list using a <dl> rather than

      Anyway to do this?

      Thanks,

      Crowspeaker

  12. crowspeaker
    Member
    Posted 8 years ago #

    Looks like my post was a little squished:

    I'll put it all into words rather than code. I want to style my category list output from wp_list_cats() using a <dl> list rather than an unordered list.

    How do I do this?

    Thanks in advance.

  13. amarfresh
    Member
    Posted 8 years ago #

    are you calling list_cats() or wp_list_cats() more than once? it appears that list_cats() can only be called once. if used elsewhere on the same page it results in no categories. perhaps that is your problem?

    there is a separate thread started specifically on this problem:
    http://wordpress.org/support/topic/26112/rss/

  14. lquilter
    Member
    Posted 8 years ago #

    the <dl> list guy: do you mean that you want parent-child categories, with the children categories hierarchical? there is a hierarchical=TRUE setting in wp_list_cats that does that.

    The solution posted here

    http://www.kahsoon.com/2005/05/10/wordpress-hierarchical-category-indent/

    worked for me.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.