The above code won't work correctly in my PHP code when I have multiple categories & sub-categories with the same displayed name Eg. Ford > 2400 and Hyundai > 2400. It provides an incorrect URL for one of the categories under the same name (2400).
How can I resolve this? How else can I load my category attribute for it to be accurate to it's URL value?