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.
- filter hook
wp_list_categories
- How to get current_cat in navbar, in single post
- Programmatically Add Font-Awesome Icons to Category Widget
- WordPress - Advanced customize function wp_list_categories
Walker_Category
class
- wp_list_categories: get latest featured_image of category
- How can I make wp_list_categories output li with category-slug as class, for its children?
- How to display a category list in a mediawiki like way?
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.