Ordering categories (20 posts)

  1. aerojad
    Posted 10 years ago #

    Hello. I'm trying to find out what is going wrong when I try to order categories by name. This is the code in the presentation:

    <?php list_cats(1, 'All', 'name', 'asc', '', 1, 0, 1, 1, 1); ?> - it came with the style I downloaded, actually. The result that produces is :

    Site News (1)
    American Politics (57)
    Movies (44)
    Music (51)
    Fcked World (51)
    Sports (37)
    Technology (53)
    TV (40)
    World News (45)
    Opinions / Rants (1)
    Canadian Politics (8)

    Not quite in order. I checked with the Codex and sort asc by name is what I want, right?

    Thanks for any help.

  2. vkaryl
    Posted 10 years ago #

    I could be wrong (am, lots!) but if you want to go from "A" to "Z", I think it's descending?

  3. aerojad
    Posted 10 years ago #

    Still... it's not even ordering it backwards...

  4. Kafkaesqui

    Posted 10 years ago #

    It's a bug. Download this file:


    Replace the one in your wp-includes/ directory.

  5. aerojad
    Posted 10 years ago #

    I did that and it broke something...

    before & after

  6. Kafkaesqui

    Posted 10 years ago #

    I just grabbed a copy of the template-functions-category.php I linked to and dropped it into two different WP setups. No problems with it, and no idea why (or how) it could affect the display of your blog as you show.

  7. josquin
    Posted 10 years ago #

    I was having the same problem and tried downloading the new template-functions-category.php. When I did so, the ordering and hierarchical display were fixed. Unfortunately, the spacing is now a little strange, like so:

    • Family (1)
      • Simon (34)
    • Flowers (3)
    • Uncategorized (4)

    Is this a CSS problem? Seems like I get one extra line for each </ul>, and because there's an extra </ul> for the nested category, I get two blank spaces after the nested category. It's not that bad, but it makes for sort of a disjointed-looking list.

    EDIT : I can't get this to look right in my post. Anyway, there's a lot of extra space under "Simon".

  8. pezastic
    Posted 10 years ago #

    Somewhat related to this, I just tried it on my site and got a call to undefined function wp_list_cats() in my sidebar.php file.

    Here is the current tag in my sidebar.php file:

    <?php wp_list_cats('optionall=0&sort_column=name'); ?>

    If I need to change wp_list_cats to list_cats, what tag would produce the same list?

  9. josquin
    Posted 10 years ago #

    I'm also now getting this:

    Fatal error: Call to undefined function: get_category() in /(path-to-blog)/wp-includes/template-functions-category.php on line 104

    When I try to edit a post.

  10. Michael Adams (mdawaffe)
    Posted 10 years ago #

    If you're talking about any in-development-versions (which you are if you're downloading stuff from trac/trunk), you should be discussing things on the Testers Mailing List.

    See also http://wordpress.org/download/nightly/

    The Forums discuss only stable (misnamed perhaps :)) releases.

    Also, downloading only one file can be dangerous. File structures change between versions. If I had to guess, a template function file wouldn't hurt you, but that's a guess.

  11. aerojad
    Posted 10 years ago #

    I'm using the 1.5 final. Does that help?

  12. josquin
    Posted 10 years ago #

    Yeah, I'm using that version as well. I just switched back to the old version of templates-function-category.php because the version linked above doesn't seem to be working properly either - basically I guess the category function needs some work and is in development?

  13. pezastic
    Posted 10 years ago #

    So, I shouldn't conclude that the wp_list_cats function is deprecated just yet?

  14. Kafkaesqui

    Posted 10 years ago #

    Ok, sorry folks. Download this one instead (earlier revision #, and *really should* work this time):


  15. melyviz
    Posted 10 years ago #

    I can't order my category list to ascend or descend, tried both template_functions_category.php and neither worked. The code is this: <?php wp_list_cats('sort_order=asc'); ?>
    I'm using wp1.5 final.
    Any idea?

  16. aerojad
    Posted 10 years ago #

    Re: Kafkaesqui's last post


    Thank you very much :)

  17. josquin
    Posted 10 years ago #

    melyviz -

    You'll want to use 'sort_column=name' as well, if you want to sort by name. WP will sort by ID by default.

  18. pezastic
    Posted 10 years ago #

    That one worked like a charm. Thanks Kafkaesqui!

  19. melyviz
    Posted 10 years ago #

    josquin: fine now, thank you.

  20. craigm
    Posted 9 years ago #

    I have a similar question. I would like to order my posts NOT based on dates or names, but based on my own numbering.

    I thought of adding a custom field called "Ranking", but can I do this at a category level instead of post level?

    So I need to customize as follows:

    1. Add a custom field to the description of the categories called ranking, and be able to rank categories as 1, 2, 3.

    2. Add a custom field to the fields in each category, so that I can rank posts in each category as 1,2,3.

    Would appreciate some thoughts.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.