get_the_category question
-
Hi all, just having a weird issue with get_the_category()
Maybe I’m not reading things right, but this should be able to retrieve the category to which a specific post belongs correct?
What I need to do is determine what the super parent to a post is. For example I have a post inside of Therapy, which inside of Procedures. So the structure is like this
Procedures -> Therapy -> the post
Procedures has a header graphic and has 4 different sub categories, so I want to display the correct header graphic no matter which post is being looked at.
I am using get_the_category() but its returning something weird.
$category = get_the_category(); echo $category[0]->name;
If I do this, the echo returns “Practices” which is a completely different parent category. It has nothing to do with the post. I’m sure I’ve just made a simple error somewhere, but it does seem a little strange…
any help greatly appreciated!
Thanks.
- The topic ‘get_the_category question’ is closed to new replies.