Created
May 15, 2012 12:15
-
-
Save imjjss/2701294 to your computer and use it in GitHub Desktop.
insert term
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? 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