• currently, the_category sorts the categories of a single post alphabetically. i actually need it to sort by ID number, like I think it used to in the beginning.

    Anyway to do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • That’s funny, because when it used to sort by ID, the Category Sort plugin was created to sort by category name.

    Didn’t test this but wonder if you changed line 80 in
    wp-includes/category-template.php (v2.3.1)

    from
    usort($categories, '_usort_terms_by_name');

    to
    usort($categories, '_usort_terms_by_ID');

    Of course any other uses of get_the_category would also be in that order.

    Make sure you make a copy of that file before trying this.

    Thread Starter nocturnea

    (@nocturnea)

    worked like a charm. thanks!

    Just wanted to thank you for that. I’ve been trying to mess with the categories order but it was sorted alphabetically, indeed.

    By the way, is there a way to invert the order? I mean, it would still sort by ID but like 3,2,1 and not 1,2,3 ?

    If not, it’s not a big deal.

    Thanks a lot MichaelH.
    It works prefectly also in 2.5.1 and it saved me a lot of headhaces!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘the_category sort by ID’ is closed to new replies.