Just wondering what the best way to get the top-most level category (grandparent) of a given category assuming it has one?
Example structure:
Operating Systems
– Mac
– – Mountain Lion
– Windows
– – Windows XP
I want to be able to somehow get the ID of the “Operating Systems” category from within the Windows XP category.
Any suggestions?
You could write a simple function to do this each time you need to. Here’s an example I found on this website.
Then you can use this function anywhere like so:
Reading the comments in the code it is pretty self-explanatory. Hope this helps.