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.
alfaspider71
Member
Posted 6 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!
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.
alfaspider71
Member
Posted 6 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.
What happens if you put "children=0"?
alfaspider71
Member
Posted 6 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?
twistedlink
Member
Posted 6 years ago #
Thanks for finding a solution to this prob. It's been driving me nuts!
@twistedlink
can i know the solution
@msmeritt
i didn't get you ,can you throw the code here.i need badly many of us too ....
twistedlink
Member
Posted 6 years ago #
I just used alfaspider's hack and so far it's been working just fine.
For me also it's working fine so far
For me also it's working fine so far
For me also it's working fine so far
There is no better solution for the time being. Stay tuned for future enhancements.
Braydon
Member
Posted 6 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
HarryRAR
Member
Posted 6 years ago #
Braydon
Member
Posted 6 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.
twistedlink
Member
Posted 6 years ago #
YES! Thanks braydonf. This is perfect.