Support » Fixing WordPress » How do you sort “the_category” tag alphabeticall

  • It appears that wordpress is sorting it by category ID. The only available parameter is to specify a separator.
    Keep in mind, I’m not referring to the “list_cats” tag which has about a dozen a dozen parameters and exists outside the loop. I’m referring to the “the_category” tag which exists inside the loop and is specific for each entry.

Viewing 4 replies - 1 through 4 (of 4 total)
  • wp-includes/template-functions-category.php
    Line 10,12,12 are what you are looking for, I think…
    WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID

    change to
    WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID ORDER BY category_nicename

    Should do the trick.

    Thanks, but it didn’t work.

    I got it to work by changing the PRIMARY Index on the wp_categories table in the database. The tricky part was getting all the indexs right.
    First, I changed the PRIMARY to a simple index and renamed it.
    Next, I changed the cat_name index from Unique to Primary.
    Finally, I added the cat_name index, as a Unique index, back into the indexs for this table.

    Worked like a charm, but if you’re even a little hesitant messing with the SQL database, I don’t reccomend trying it.

    This plugin sorts the category list outputted by the_category() in alphabetical order.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do you sort “the_category” tag alphabeticall’ is closed to new replies.