title: Create categories and multiple subcategories programmatically
body: <p>This code show properly category in wordpress admin area. but not showing subcategory.</p>
  
  <p><strong>I Need to show 3 categories and 3 subcategories for each category?</strong></p>
  
  <p>This is what I would like to have for each category:</p>
  
  <p>Category A</p>
  
  <ul>
  <li>sub-category 1</li>
  <li>sub-category 2</li>
  <li>sub-category 3</li>
  </ul>
  
  <p>I have add the following code in wordpress theme's functions.php file:</p>
  
  <pre><code>//create the main category
  wp_insert_term(
  
  // the name of the category
  'Category A', 
  
  // the taxonomy, which in this case if category (don't change)
  'category', 
  
   array(
  
  // what to use in the url for term archive
  'slug' =&gt; 'category-a',  
   ));`
  </code></pre>
  
  <p><strong>Then for each sub-category:</strong></p>
  
  <pre><code>wp_insert_term(
  
  // the name of the sub-category
  'Sub-category 1', 
  
  // the taxonomy 'category' (don't change)
  'category',
  
  array(
  // what to use in the url for term archive
  'slug' =&gt; 'sub-cat-1', 
  
  // link with main category. In the case, become a child of the "Category A"   parent  
  'parent'=&gt; term_exists( 'Category A', 'category' )['term_id']
  
  ));
  </code></pre>
  
  <p>But I am getting an error: </p>
  
  <blockquote>
    <p>Parse error: parse error, expecting `')'' in line 57 …</p>
  </blockquote>
  
  <p>Corresponding to <code>'parent'=&gt; term_exists( 'Category A', 'category' )['term_id']</code>.</p>
  
  <p>What I am doing wrong?</p>