Site icon Hip-Hop Website Design and Development

Edit the_category (); for a hierarchical display

For my wp theme I want to use the categories as tags on my posts.
Example:

The problem is that the category in red must always be the parent and in gold the child.

Except that returns the categories to me in alphabetical order and not in hierarchical order, so sometimes I end up with the child in red and the parent in gold …

Knowing that I would only use 2 categories per posts so 1 = the parent and 2 = the child

Do you have a solution?