How to alphebetize `the_category`? (4 posts)

  1. JoeyDay
    Posted 11 years ago #

    When listing categories on an individual entry, they always get displayed in the order I created the categories (by category ID). I know list_cats has a sort_order argument, but is there any way to alphabetize the_category?

  2. antiheroine
    Posted 10 years ago #

    I tried searching for the answer to this, but came up with nothing. I would also like to know how to alphabetize the_category.

  3. MichaelH
    Posted 10 years ago #

    Interesting method used here was to change the Primary Index on the wp_categories table:

    This feature to sort the_category by name has been requested in Trac:

  4. MichaelH
    Posted 10 years ago #

    This seems to work in 1.5.2 and will even cause the Manage->Posts screen to show each Post's categories sorted alphabetically by the category-nicename field.

    In wp-content/template-functions-category.php in the get_the_category functions at line 15 you should see sort($categories)

    change that line to:

    usort($categories, create_function('$a,$b','return strcasecmp($a[2],$b[2]);'));

    Of course, remember to backup the wp-content/template-functions-category.php file before making this change just in case it doesn't work for you.

Topic Closed

This topic has been closed to new replies.

About this Topic