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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Creating two subterms for parent term in taxonomy "software-developers" while publishing parent term.
function subterms_for_software_term( $term_id, $tt_id ) {
var_dump(func_get_args()); die;
if ( is_admin() && is_tax( 'software-developers' ) ) {
$parent_term = get_term($term_id, $tt_id);
if(!is_wp_error($parent_term)) {
$taxonomy = 'online-casinos';
wp_insert_term(
$parent_term->name.' Bonuses',
'software-developers',
array(
'description' => '',
'parent' => $parent_term['term_id'],
'slug' => 'bonuses-'.$parent_term->slug,
)
);
delete_option($taxonomy."_children");
wp_cache_flush();
wp_insert_term(
$parent_term->name.' Bonuses',
'software-developers',
array(
'description' => '',
'parent' => $parent_term['term_id'],
'slug' => 'bonuses-'.$parent_term->slug,
)
);
delete_option($taxonomy."_children");
wp_cache_flush();
}
}
}
add_action( 'create_term', 'subterms_for_software_term', 10, 2 );