Skip to content

Instantly share code, notes, and snippets.

@imjjss
Created May 15, 2012 12:15
Show Gist options
  • Save imjjss/2701294 to your computer and use it in GitHub Desktop.
Save imjjss/2701294 to your computer and use it in GitHub Desktop.
insert term
<? php
function insert_term($term, $taxonomy, $args = array()) {
if (isset ( $args ['parent'] )) {
$parent = $args ['parent'];
} else {
$parent = 0;
}
$result = term_exists ( $term, $taxonomy, $parent );
if ($result == false || $result == 0) {
return wp_insert_term ( $term, $taxonomy, $args );
} else {
return ( array ) $result;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment