Title: Category priority problem
Last modified: August 19, 2016

---

# Category priority problem

 *  [dodfr](https://wordpress.org/support/users/dodfr/)
 * (@dodfr)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/category-priority-problem/)
 * Hi,
 * When wordpress show categories of a post it do it in alphabetical order, but 
   is there some way to make parent->child categories prioritized ?
 * For example let say I have a main category “Software” with a child “Internet”
   that have itself two childs “Security” and “Firewall”.
 * Now if I create a post will all thoses categories checked the post will show “
   Category : Firewall, Internet, Security, Software” instead of what I would like“
   Software, Internet, Firewall, Security”.
 * regards.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/category-priority-problem/#post-1255263)
 * Actually, I think the categories are displayed in ID order. It just so happens
   that, in your case, that’s also the alphabetical order. There’s no parameter 
   to alter this ordering in [the_category()](http://codex.wordpress.org/Template_Tags/the_category)
   but you could perhaps try using [get_the_category()](http://codex.wordpress.org/Function_Reference/get_the_category)
   to get the categories for a post in an array and then sort the array alphabetically
   before displaying the category links.
 *     ```
       <?php
       $catlist = get_the_category();
       asort($catlist);
       $tot = count($catlist);
       $n = 0;
       foreach($catlist as $category) {
           $n++;
           echo '<a href="' .$category->category_nicename. '">' . $category->cat_name . '</a>';
           if( $n < $tot ) echo ', ';
       }
       ?>
       ```
   
 *  Thread Starter [dodfr](https://wordpress.org/support/users/dodfr/)
 * (@dodfr)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/category-priority-problem/#post-1255310)
 * [@esmi](https://wordpress.org/support/users/esmi/),
 * Thanx for your answer but actually WordPress already show it alphabeticaly sorted
   when the Post is displayed in main page or as single post, but I don’t want it
   to be like that, I want it to show parent-to-child sorted categories and if post
   is part of categories at same level, then do an alphabetical sort.
 * regards.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Category priority problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [dodfr](https://wordpress.org/support/users/dodfr/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/category-priority-problem/#post-1255310)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
