Determine if term is Category or Tag

Solution below 🙂

I when through how WordPress determines if the term is category or tag. I found that there is an attribute called ‘hierarchical’ – it went down the hill from there.

I found a nice little function called is_taxonomy_hierarchical() and I fixed the issue with two if statements.

if(is_taxonomy_hierarchical($taxonomy)) {
                            if(isset($term[0]->name)) {
                                if($term[0]->parent > 0) {
                                    $categories .= $parent . ' > ' . $term[0]->name . ',';
                                } else {
                                    $categories .= $term[0]->name . ',';
                                }
                            }
                        }

                        if(!is_taxonomy_hierarchical($taxonomy)) {
                            if(isset($term[0]->name)) {
                                $tags .= $term[0]->name . ',';
                            }
                        }

Hope this will be helpful to someone in future!