function create_cat_settings() {
wp_create_category( 'Videos' );
$parent_term_a = term_exists( 'Videos', 'category' ); // array is returned if taxonomy is given
$parent_term_a_id = $parent_term_a['term_id']; // get numeric term id
// First subcategory
wp_insert_term(
'World', // the term
'category', // the taxonomy
array(
// 'description'=> 'Some description.',
'slug' => 'world',
'parent'=> $parent_term_a_id
)
);
// Second subcategory
wp_insert_term(
'Movies', // the term
'category', // the taxonomy
array(
// 'description'=> 'Some description.',
'slug' => 'movies',
'parent'=> $parent_term_a_id
)
);
// Third subcategory
wp_insert_term(
'Circket', // the term
'category', // the taxonomy
array(
// 'description'=> 'Some description.',
'slug' => 'circket',
'parent'=> $parent_term_a_id
)
);
wp_insert_term(
'Tech', // the term
'category', // the taxonomy
array(
// 'description'=> 'Some description.',
'slug' => 'tech',
'parent'=> $parent_term_a_id
)
);
wp_insert_term(
'Auto', // the term
'category', // the taxonomy
array(
// 'description'=> 'Some description.',
'slug' => 'auto',
'parent'=> $parent_term_a_id
)
);
wp_insert_term(
'Top News', // the term
'category', // the taxonomy
array(
// 'description'=> 'Some description.',
'slug' => 'top-news',
'parent'=> $parent_term_a_id
)
);
}
add_action( 'admin_init', 'create_cat_settings' );
Jagdish Sarma Asked question September 21, 2022