• Resolved poodlerat

    (@poodlerat)


    I’ve upgraded to 2.1 and changed

    wp_list_cats('sort_column=name&hide_empty=0&exclude=1')

    to

    wp_list_categories('orderby=name&hide_empty=0&exclude=1&title_li')

    in my sidebar.

    I have no posts in any of my link categories, and no links in any of my post categories, but my link categories are being displayed in the list along with my post categories. How do I get rid of them?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Might not be what you want but by deleting the &hide_empty parameter, it will stop showing the categories you’ve got associated with links.

    Thread Starter poodlerat

    (@poodlerat)

    Thanks, but I can’t do that, because my post categories are organized within empty parent categories. If I hide the empty categories, none of my categories will show.

    I’ve sort of fixed it by excluding all the link categories, but it’s not a permanent solution – I shouldn’t have to go back and change my template every time I want to add a new link category.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Try adding “type=post” to your query string. See if it helps.

    Or you could put your Link Categories under a single parent, and then exclude that parent.

    Unless you do the exclude, such as you and Otto42 suggested, given the current wp_categories structure, I guess you can’t always know that a given Category is a post category or a link category.

    It seems if there is a non-zero value in the category_count field, that Category is considered a post category, and if link_count has a non-zero value it is considered a link category. But if both fields are zero then what kind of Category is it?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Near as I can tell, it’s both until such time as you put a post under it or put a link under it. I dunno, that bit is slightly confusing.

    Thread Starter poodlerat

    (@poodlerat)

    “type=post” did absolutely nothing, and when I checked the wp_list_categories page in the codex, it wasn’t listed as one of the possible paramters, so I’m kind of confused about it.

    But I tried deleting the hide_empty parameter, just to see what would happen. I thought it would behave as I described above, but it didn’t – all my post categories are showing up, even the empty parent ones and all their children. Which is very, very weird – the fact that empty parent cats wouldn’t show up (even if their child cats weren’t empty) prior to 2.1 was the reason I had it set to hide_empty=0 in the first place. In terms of template tag behaviour, the jump between 2.0 and 2.1 has been bigger than between 1.5 and 2.0, which is unexpected.

    Anyway, thanks for your help!

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    type=post/link is not in the codex yet. 2.1 is too new for all the codex changes to have been made.

    @otto42:

    Am I missing something? I’m not seeing that ‘type=’ parameter in category-template.php.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Yep. Notice how it passes along the args to get_categories() in the form of an array? Might check the params for get_categories() as well.

    Cool. And I see R. Boren suggested get_categories in a wp-testers thread:

    Or get_categories(‘type=link’)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘wp_list_categories() post and link categories – WHY?’ is closed to new replies.