WordPress.org

Ready to get started?Download WordPress

Forums

Avoid to display sub categories with WP 2.1 (20 posts)

  1. damino
    Member
    Posted 7 years ago #

    Hi, since I upgrade to WP 2.1 I can't succed on displaying only parent categories (even them with children)

    In WP 2.0.7 I use to ise the template tag wp_list_cats with the argument children set to 0
    But now that this template tag is depreciated it seems that it doesn't work.
    I've red the code of the new template tag wp_list_categories, but I can't find the argument 'children'

    Any suggestions ? Thanks.

  2. alfaspider71
    Member
    Posted 7 years ago #

    damino -- I have exactly the same issue. I was short on time to find the real answer, so here's my temporary ugly hack:

    Call wp_list_cats (or wp_list_categories) with the children=1 argument. Subcategories will be in the "children" class. I just added:

    .children { display: none; }

    to my CSS file. This works while I figure out how to address the issue.

    With that out of the way, how do I *really* fix this? Inquiring minds want to know! Thanks!

  3. damino
    Member
    Posted 7 years ago #

    Thanks for this hack.
    We're working to find the "normal" way to resolve this on WordPress-net.fr

    I'will come here again if we find an issue.

  4. alfaspider71
    Member
    Posted 7 years ago #

    Great -- if you find the answer, definitely post it here.

    I could fix it by modifying the core files, but it's best not to touch those for the sake of future upgrades.

  5. damino
    Member
    Posted 7 years ago #

    We are not alone ... (look at comments ...)
    http://ericulous.com/2007/01/22/migrating-wordpress-20-themes-over-to-wordpress-21/

    Still no solutions ...

  6. DianeV
    Member
    Posted 7 years ago #

    What happens if you put "children=0"?

  7. alfaspider71
    Member
    Posted 7 years ago #

    We're not alone, you're right. Maybe I'll have to write a plugin to remove everything in the "children" class of the wp_list_categories output until this gets fixed in the core files (assuming it will be fixed).

    I wonder why it was removed?

  8. twistedlink
    Member
    Posted 7 years ago #

    Thanks for finding a solution to this prob. It's been driving me nuts!

  9. xinfo
    Member
    Posted 7 years ago #

    @twistedlink

    can i know the solution

  10. xinfo
    Member
    Posted 7 years ago #

    @msmeritt

    i didn't get you ,can you throw the code here.i need badly many of us too ....

  11. twistedlink
    Member
    Posted 7 years ago #

    I just used alfaspider's hack and so far it's been working just fine.

  12. xinfo
    Member
    Posted 7 years ago #

    For me also it's working fine so far

  13. xinfo
    Member
    Posted 7 years ago #

    For me also it's working fine so far

  14. xinfo
    Member
    Posted 7 years ago #

    For me also it's working fine so far

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    There is no better solution for the time being. Stay tuned for future enhancements.

  16. Braydon Fuller
    Member
    Posted 7 years ago #

    i think i got something to work
    download and install this plugin
    http://braydon.com/unfold_list_categories.zip

    to only show 1 level of categories use this:
    <?php unfold_list_categories('depth=1&hierarchical=1'); ?>

    in place of this:
    <?php wp_list_categories(); ?>

    let me know if it works for you... it worked for me but it was sort of by accident i think

  17. HarryRAR
    Member
    Posted 7 years ago #

    Yup, works for me :)

  18. Braydon Fuller
    Member
    Posted 7 years ago #

    great. good to hear.

  19. Lorelle
    Member
    Posted 7 years ago #

    Also try:

    <?php wp_list_categories('show_count=1&use_desc_for_title=0&title_li=0&exclude=1, 16, 28, 29, 44, 72, 9'); ?>

    This will show a list of the categories without a title (such as "categories", if you have your own title), with a post count per category, and shows the list of categories EXCEPT for the ones listed. List as many as you want NOT to appear in the list.

  20. twistedlink
    Member
    Posted 7 years ago #

    YES! Thanks braydonf. This is perfect.

Topic Closed

This topic has been closed to new replies.

About this Topic