I created custom taxonomy called Products. It has three terms (categories): Furniture, Gift, Food. Each term has it's own children (subcategories). And I need to get a posts titles, who are in the specific subcategory.
I have a code, which displays specific category (which term_id is 3) subcategories titles:
<?php
$termID = 3
$taxonomyName = "products";
$termchildren = get_term_children( $termID, $taxonomyName );
foreach ($termchildren as $child) {
$term = get_term_by( 'id', $child, $taxonomyName );
echo'<p class="menu_head"><a href="#">'.$term->name.'</a></p>
<div class="menu_body">
<a href="#">Link-1</a>
<a href="#">Link-2</a>
<a href="#">Link-3</a>
</div>';
}?>
And I need to get posts, who are in that subcategories, titles in <div class="menu_body"></div> instead of "Link-1", "Link-2", "Link-3".