Creating two subterms for parent term in taxonomy software-developers

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// Creating two subterms for parent term in taxonomy "software-developers" while publishing parent term.
function subterms_for_software_term( $term_id, $tt_id ) {
if ( is_admin() && is_tax( 'software-developers' ) ) {
$parent_term = get_term($term_id, $tt_id);
if(!is_wp_error($parent_term)) {
wp_insert_term(
$parent_term->name.' Bonuses',
'software-developers',
array(
'description' => '',
'parent' => $parent_term['term_id'],
'slug' => 'bonuses-'.$parent_term->slug,
)
);
}
}
}
add_action( 'create_term', 'subterms_for_software_term', 10, 3 );
do_action( "create_term", $term_id, $tt_id, 'software-developers' );