I am trying to get 2nd level category of a single Post.
A Post is under this hierarchy Sports > Football > premier league
i want to get the ID for Sport how can i do this.
Thank You.
I am trying to get 2nd level category of a single Post.
A Post is under this hierarchy Sports > Football > premier league
i want to get the ID for Sport how can i do this.
Thank You.
You can get all first level categories by this code for particular post
$cat = get_the_category($post_id);
then by this one you can get child categories
$child_categories=get_categories(
array( 'parent' => $cat->cat_ID )
);