views:

30

answers:

1

So if I'm on a subcategory page...how can I get the name of the main category? So let's say I'm on site.com /my-category/my-subcategory/ so how can I get "my-category" ? I don't want to parse the url :) cuz' I think wordpress has a built in function or smth.

Best Regards,

A: 

I've solved this by using get_the_category()) and ->category_parent

Uffo
Remember to do this multiple times if needed, if you want the top category and your nested goes beyond two levels. The closest related function is probably [`get_category_parents`](http://codex.wordpress.org/Function_Reference/get_category_parents).
Jan Fabry