how do I get taxonomy based node content through custom query? I have taxonomy terms displayed using drupal api function. Now I need to fetch content based on terms id or name from database? Can any one please help me.Either using entity field query or SQL?
$tree=taxonomy_get_children(1);
foreach ($tree as $term)
{
$item[] = $term->name;
$child_term = taxonomy_get_children($term->tid);
if (!empty($child_term))
{
<a href="?name=<?php print $term->tid; ?>">
<?php
print $term->name."<br>";
?>
</a>
foreach ($child_term as $child)
{
$item[] = $child->name;
<a href="?tid=<?php print $child->tid; ?>" name="tid">
<?php
print $child->name."<br>";
?>
</a>
<?php
$nodes = taxonomy_select_nodes($child->tid);
$node = node_load_multiple($nodes);
$nidd=(int)$node->nid;
foreach($node as $node1):
$tids = field_get_items('node', $node1, 'field_product_sub_cat');
foreach ($tids as $tid){
if($tid['tid'] == $child->tid){
print $node1->title;
print render(field_view_field('node', $node1, 'body'));
}
}
endforeach;
else
print $term->name."<br>";