Site icon Hip-Hop Website Design and Development

List post from current taxonomy children

I have a custom post type and a taxonomy with children, with a template file named taxonomy-productcategories.php. On this i want to list all children with their posts.

And so on…

I have an example for getting just the Child taxonomy, but i want to add the post from each taxonomy.

<?php
$term_slug = get_query_var( 'term' );
$taxonomyName = get_query_var( 'taxonomy' );
$current_term = get_term_by( 'slug', $term_slug, $taxonomyName );
$termchildren = get_term_children( $current_term->term_id, $taxonomyName );

foreach ($termchildren as $child) {
    $term = get_term_by( 'id', $child, $taxonomyName );
    echo "$term->name:<br />"; 

}
?>