Categories – What’s the deal?
Ok, I’ve been seeing more and more posts about “missing” categories in the menu. It seems that if a parent category doesn’t explicitly have a post tied to it, it and it’s child categories will not show up; even if the child categories do have posts.
1) Is this true? I thought Mingus would finaly be my chance to get caught up on installs. But not if this is the case.
2) Is this by design, or is it a side effect of something? If it is by design, why was is done and is there a way to override it? If it is a bug, any idea on when it might be fixed?
I’m looking for answers by people in the know, and not rumors or inuendo. I have a category that has sub cats, and the posts only go into the sub cat, not the parent (because it wouldn’t make sence) so this issue is very importaint to me.
I can definitively answer only question #1:
Yes, it’s true: if a top-level category has no posts in it, and a sub-category has posts, then the top-level category and all sub-categories are suppressed in the category list.
This is how the new wp_get_cats work. Remember, previous versions of WP had no parent directories, so this behavior is how it has always behaved. 😛 It’s all documented in the Wiki.Anonymous
wp_list_cats("children=TRUE&hide_empty=0")will list the child categories even if the parent is empty.
If there are empty categories that show up that you don’t want just add
nis the ID of the category you want to exclude.
welsper – I’m not so sure that’s how it’s *always* behaved. I’m currently using sub-cats (an old 1.1Alpha version), and that’s NOT the behavior I get. I want to make sure that I will be able to continue using them the way I have been.
The clue may be in Stewart’s post about hide_empty=0 — I may have that turned on.
georgianlady – except that I DO want the sub cats underneath the parent cat, indented no less. If you take a quick look at my site as it is right now (unless you use IE, then don’t bother, it’s messed up) you’ll see that I have three categories under Writings & Scribblings. There will never be a post directly under W&S, they everything in there will always go in to one of those three sub cats.
And I could never get the post count option wot work right either. OK, so bottom line is that it looks like I need to make a back up of everything, make a copy, and upgrade my site as it is, and see what happens.
Add that to my list of things to get done someday.
I’m still getting that behavior as well on my test install. I haven’t tried Stewart’s solution yet, but will give it a try.
On my live site, I’m still “faking” it, but it’s working well. I simply create a link category for each parent category, then create links to each sub category. So, I don’t really display categories at all…just links. If Stewart’s solution works, then I can abandon the workaround…
TechGnome– 1.1 was never an official release. 1.0x >> 1.2 is the official upgrade path, and, well, parent/child cat didn’t exist in 1.0x.
If you are running a fresh, unmodified version of wp 1.2, and have
<?php wp_list_cats('hide_empty=0'); ?>, then all of your categories should display, irregardless of posts in them, and they will be indented properly according to child/parent status.
I have a problem with categories and wonder if any of you has experienced it:
I want to display all top categories (my top level menu) and then, depending on which cateory the user is in, I want to diplay this category’s subcategories in another menu.
I cannot, however, turn off subcategories, even though I use (‘children=0’). The only difference it makes is that with ‘0’ the subcategories appear like top categories and with ‘1’ they appear as proper childs.
Is this a bug or intended?
Using (‘children=0’) as you are stating only makes the toplevel AND the subcategories ALL show up in one non-indented list. It’s how I have my categories listed, and I posted about that earlier in this thread, how I found the “0 or 1” functionality with children, when the WIKI says to use “true or false”.
True, False, and 1 all do the same thing, indent subcategories under their toplevel category parent, and ONLY show Toplevels that have posts in them unless you use “hide_empty=0” to show ALL categories Parent with indented children. Otherwise it’s just Parent that has posts in it, and indented children with posts in them.
0 shows ALL categories that have post in them, but ONLY categories that have post in them, even if their toplevel parent has NO post in it. This is the only useful way I’ve found to use the category listing, as I don’t want people not to see a listing that does have content, and also don’t want them to see a link to a page with ”Sorry, no posts matched your criteria.” as the result of clicking the link.
I think it’s a bug, but it’s a bug that I like the “0” functionality of. Just not the “true, false, or 1” parts of it, as they all do the same thing. And since the rule in the WIKI template tags for children in wp_list_cats says this:
children - boolean - TRUE or FALSE; Whether you want to hide or show the children of the main categories (top categories only)
It makes me think it must be a bug. Sigh. I recall when going over my frustration with category listings that time that the other attributes weren’t all right either. So affecting the listing how I did was a delight, and an accident, as I said earlier.
So re-reading the post above I find that in my installation “children=0” take the children and lines them up as-if a top level category, but the only the categories that have at least one post in them show up.
Using “children=”1” makes the children show as sub-level under top level, indented in the list, but only the top categories that have posts in them show, if there are top categories that are empty, but their child categories have posts in them, both top and child are suppressed. You can use hide_empty here, and it gets confusing as to what’s what, as I’m playing with it now on my site. Using Children=0 and hide_empty=1 and the other possibilities with both. Try playing with your site like that, having two identical listings and use the same attributes with opposite effects, or more lists than that just to see what happens all at one time to avoid confusion, as I am in right now 😉
All in all, what you are asking, I think is not possible right now. I can’t get the thing to do whatever my first objective was, and so now that I found a way to make everything show up as a toplevel if it’s not empty, then that’s alright.
It’d be helpful if each tag had actual consistent examples of HOW to use each attribute. I get stuck sometimes, and I know that’s what was helpful for me when using MT, the examples of how-to in the manual.
I am guessing that since category stuff is new to 1.2 that it’ll improve over time, but isn’t fully functional yet, though I haven’t seen anywhere state that the “children” thing isn’t working right, ‘cept here, not that I’ve exhaustively searched for it, mind you.
I hope this isn’t too overly redundant, I’ve come back to this multiple times as writing it while messing with the category tags. Another weary-ing thing, dumb to do to myself with all the junk I’ve done today with WP, but hey, when you have a Summer Cold, what more is there to do that mess with ones blog config. 🙂
Thanks for the extensive answer 🙂
It really seems that it is a bug, because (‘children=0’) should definitely turn off all child categories, and it doesn’t.
For my current blog it’s no big deal, I will hardcode the six top categories and pray that at least the children_of function works properly, so I can display the subcategories dynamically. But for further blogs this won’t work, as I can’t predict the number of top categories.
In my design I want to “split” categories: the top categories are supposed to appear as a horizontal top level navigation and the subcategories are supposed to appear in the left column. And that seems not possible, at least not dynamically, because WP will always display ALL categories.
I’m new to WP, and it seems that the SourceForge bug tracker is not maintained. Any suggestions where to report this problem?
Just a quick note:
ophois already reported the ‘children=0’ bug. See http://wordpress.org/support/3/7092
hope that summer cold is not too bad
It’s a separate issue and I think we can discuss through the same page.
Waiting to hear,
Thanks in advance.
- The topic ‘Categories – What’s the deal?’ is closed to new replies.