title: Get Wordpress child category from specific parent
body: <p>I'm building a small thumbnail gallery with posts from a category that has the ID 406.</p>
  
  <p>Some of the posts are in multiple categories and I'm not sure how to grab the category name that is a child of 406. <code>$post_cat[0]-&gt;name;</code> returns a category, but I only need it to return children of 406.</p>
  
  <pre><code>$thumbnails = get_posts('posts_per_page=10&amp;cat=406');
  
  foreach ($thumbnails as $thumbnail) {
  
     $args = array(
       'type' =&gt; 'post',
       'child_of' =&gt; 0,
       'parent' =&gt; 406,
     );
     $categories = get_categories ( $args );
  
     foreach ( $categories as $category) {
        $cat_name = $category-&gt;name;
        $cat_slug = $category-&gt;slug;
     }
  
      echo $cat_name;
      echo $cat_slug;
  
   }
  </code></pre>
  
  <p><em><strong></em>*</strong><em>EDIT</em><strong><em>*</em>*</strong></p>
  
  <pre><code>$thumbnails = get_posts('posts_per_page=10&amp;cat=406');
  foreach ($thumbnails as $thumbnail) {
  
    $post_cat = get_the_category( $thumbnail-&gt;ID );
    echo '&lt;li&gt;&lt;a class="side-thumb" href="' . get_permalink( $thumbnail-&gt;ID ) . '" title="' . esc_attr( $thumbnail-&gt;post_title ) . '"&gt;';
  
    if ( has_post_thumbnail($thumbnail-&gt;ID)) {
  
     echo get_the_post_thumbnail($thumbnail-&gt;ID, 'thumbnail');
     $upload_dir = wp_upload_dir();
     $art_image = ''.$upload_dir['basedir'].'/icons/'.$post_cat[0]-&gt;slug.'.png';
  
     if (file_exists($art_image)) {
  
       echo '&lt;p class="artist-latest"&gt;&lt;img src="http://site.com/wp-content/uploads/icons/'.$post_cat[0]-&gt;slug.'.png" alt="'.$post_cat[0]-&gt;slug.'"/&gt;'.$post_cat[0]-&gt;name.'&lt;/p&gt;';
  
      } else{
          echo '&lt;p class="artist-latest"&gt;'.$post_cat[0]-&gt;name.'&lt;/p&gt;';
      }
  
      } else {
  
      }
      echo '&lt;/a&gt;&lt;/li&gt;';
     }
  </code></pre>