Skip to main content
1 of 10
Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109

Instead of using get_categories(), I'd suggest you take a look at wp_list_categories(). You can get the same output with it, but it has the benefit to be highly customizable.

There are two ways for customization, either via the filter hook wp_list_categories - see in source - or by extending the Walker_Category class - see in source. The latter gives you much more possibilities for customizing, but might be over the top for minor changes. So you have to evaluate what fits your needs best.

Because this topic is actually pretty well covered on WPSE and SO, I'll just give you a short list of references. Besides that you have not given a specific enough description of your needs, it remains a bit vague, although one can know what you want. Anyway, below resources should help you to chose the method fitting for you and additionally should enable you to achieve it.

  1. filter hook wp_list_categories
  1. Walker_Category class

One more remark, personally I would almost always opt for the extending the Walker_Category class method, but for cases where the change you want is very minor. This is of course a bit of personal preference, but has some background, particularly because of re-usability, extendability and - even if it doesn't necessary seem like it - after all it often - maybe even most of the time - is the easier way to achieve the custom output.

Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109