Title: Help Needed Customising &#8216;Categories&#8217; Function
Last modified: August 18, 2016

---

# Help Needed Customising ‘Categories’ Function

 *  [newbee](https://wordpress.org/support/users/newbee/)
 * (@newbee)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/help-needed-customising-categories-function/)
 * Hi,
 * As part of customising the way categories are displayed in my sidebar, I need
   to be able to display just the first 3 categories, ordered alphabetically (ascending)&
   show the number of posts for each of these categories.
 * Having read through the codex, the best thing I’ve been able to come up with 
   is:
 * <?php WP_list_cats (‘ sort_column=name&optioncount=1&exclude=x’);?>
    where x=
   the list of category ids I want to exclude
 * Although this will work, I have a long list of categories that need to be excluded,
   so it’s a bit clumsy, added to which, everytime I add a category, I’ll have to
   alter the code.
 * What I really want is to be able to say exclude x where where x=all categories
   with ids greater than 3, but my limited understanding of the syntax for this 
   function tell me I can’t do this…or can I?
 * Can anyone suggest an elegant solution?
 * Thanks

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

 *  [skulled](https://wordpress.org/support/users/skulled/)
 * (@skulled)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/help-needed-customising-categories-function/#post-302633)
 * How are you with PHP?
 * If you are familiar and comfortable with programming in PHP, what you could do
   is use the `list_cats` function with recurse setting set to TRUE which would 
   return the list, and then use to PHP to remove all categories that you do not
   need, and display the rest
 * Cannot think of a more ‘elegant’ way right now .. let me know if that works, 
   if it doesn’t I can try see if something else is possible.
 *  Thread Starter [newbee](https://wordpress.org/support/users/newbee/)
 * (@newbee)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/help-needed-customising-categories-function/#post-302635)
 * Thanks, but I am neither familiar nor comfortable with PHP.
 *  [skulled](https://wordpress.org/support/users/skulled/)
 * (@skulled)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/help-needed-customising-categories-function/#post-302636)
 * That is not so good .. 😉
 * In that case I am afraid I don’t see any other methods of doing what you want,
   with builtin WP functions ..
 * Maybe someone else can clarify this, but I think custom code is the only way 
   you are going to achieve what you want.

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

The topic ‘Help Needed Customising ‘Categories’ Function’ is closed to new replies.

## Tags

 * [customising](https://wordpress.org/support/topic-tag/customising/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [skulled](https://wordpress.org/support/users/skulled/)
 * Last activity: [20 years, 5 months ago](https://wordpress.org/support/topic/help-needed-customising-categories-function/#post-302636)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
