Drupal Taxonomy Term id from Path

In cases where you have a drupal taxonomy page and you need the term id you can get that by the folowing code:

 * @param $term_tid
function test_function(term_tid){
  $tid = empty($term_tid) ? arg(2) : $term_tid;

provided you have path_aliases module installed you can test the above code by creating a something like the function below i.e. hook_menu() function.

$items['taxonomy/term/%/test/' . "rss"] = array(
  'title'           => 'RSS',
  'description'     => 'RSS feed.',
  'page callback'   => 'test_function',
  'page arguments'  => array(2, 4),
  'access callback' => TRUE,

So what we are doing here we are passing argument 2. An example:


What we will have passed as argument is politics is passed