title: How to check if a category has a parent category?
body: <p>Im trying to check if 'categoryone' has a parent.
  Right know I can check and see that there is a category called categoryone, but not if categoryone has a parent category.
  I have tried to code something like the code bellow.</p>
  
  <pre><code>  $tid = term_exists('categoryone', 'category', 0);
  
    $term_ids = [];
  
    if ( $tid !== 0 &amp;&amp; $tid !== null )
    {
  $term_ids[] = $tid['term_id'];
  
    }
    else
    {
      // If there is not a parent category!
      $insert_term_id = wp_insert_term( 'categoryone', 'category' );
      if ( ! is_wp_error )
      $term_ids[] = $insert_term_id;
    }
    wp_set_post_categories( $insert_id, $term_ids );
  </code></pre>