WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. trick100
    Member
    Posted 2 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. alchymyth
    Forum Moderator
    Posted 2 years ago #

  3. trick100
    Member
    Posted 2 years ago #

    Thx alot!

Topic Closed

This topic has been closed to new replies.

About this Topic