Get category id from child category id. where is mistake? (3 posts)

  1. trick100
    Posted 3 years ago #

    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;
  2. Michael
    Part-Time Forum Moderator
    Posted 3 years ago #

  3. trick100
    Posted 3 years ago #

    Thx alot!

Topic Closed

This topic has been closed to new replies.

About this Topic