function taxonomy_get_term_by_name

You are here

7 taxonomy.module taxonomy_get_term_by_name($name, $vocabulary = NULL)
4.6 taxonomy.module taxonomy_get_term_by_name($name)
4.7 taxonomy.module taxonomy_get_term_by_name($name)
5 taxonomy.module taxonomy_get_term_by_name($name)
6 taxonomy.module taxonomy_get_term_by_name($name)

Try to map a string to an existing term, as for glossary use.

Provides a case-insensitive and trimmed mapping, to maximize the likelihood of a successful match.


name: Name of the term to search for.

Return value

An array of matching term objects.

1 call to taxonomy_get_term_by_name()
taxonomy_node_save in modules/taxonomy.module
Save term associations for a given node.


modules/taxonomy.module, line 994
Enables the organization of content into categories.


function taxonomy_get_term_by_name($name) {
  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER('%s') LIKE LOWER(", 't', 'tid'), trim($name));
  $result = array();
  while ($term = db_fetch_object($db_result)) {
    $result[] = $term;

  return $result;


should be more helpful if it takes the $vid as the second parameter allowing it to search only in certain vocabulary