• Hi everyone, i want to get category id, i got child category id from post id already. My code is not working, please help find my mistake.

    if (is_single()){
        $categories = get_the_category($post->ID);
        foreach($categories as $category) {
        $cat_id = $category->cat_ID;
        $parent = $cat_id->category_parent;
        echo $cat_id;
        echo $parent;
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get category id from child category id. where is mistake?’ is closed to new replies.