Wordpress - How to get the parent category identifier
my category is news ---->sport news
I have a sports news post.
how to get the parent (news) identifier when I enter the post of sports news?
this code is echo parent cat name
foreach((get_the_category()) as $childcat) { $parentcat = $childcat->category_parent; echo get_cat_name($parentcat); echo $parentcat->term_id;} echo $post->post_parent->cat_ID;
this code is echo the name of one page cat
global $post;$category = get_the_category($post->ID);echo $category[0]->name;
this id eode chode named cat
$category = get_the_category(); echo $category[0]->cat_ID;
I need a parent id echo (cat_ID) plz help me
thanks.
source share