programmatically getting custom node belonging to a term have searched google but cannot find anything specific . Intention is to get all Custom Node types that have been assigned a specific term of vocabulary . for example the follwoing is a db query to get custom node type.

$query-&gt;condition('type', "news_article")-&gt;fields('n',array('nid'))-&gt;orderBy('created', 'DESC')-&gt;range(0,90);

can the same query be modified to also add the  filter for term id . 

One other related question is that how can (in PHP) we get the term id from the url of the pattern e.g &lt;drupal site&gt;/taxonomy/term/2 . 

any help appreciated
This might be helpful

How to use EntityFieldQuery

It works great for me. As far as the other question is concern, there are many ways of doing this. the simplest would be below, provided that you are accessing link in your question:

&lt;?php
    $arg0 = arg(0);
    $arg1 = arg(1);
    $arg2 = arg(2);

    echo $arg0; //this will echo 'taxonomy'
    echo $arg1; //this will echo 'term'
    echo $arg2; //this will echo 2 (term ID)
?&gt;


Info about arg() can be found here: arg()