I'm writing a plugin for adding a Custom Post called"Dog". The core of the plugin is strictly based on this one https://github.com/RescueThemes/Rescue-Animal-Custom-Posts
I prefer to add predefined sexes after the plugin activation, I would like to add "Male", "Female", "Unapplicable" from the start.
So, based on other resources I wrote that in the same .php plugin file
Consider that I changed the taxonomy name from "Genders" to "Sexes" from the original plugin.
add_action( 'init', 'create_dog_taxonomies', 0 );
function create_dog_taxonomies() {
// Sex taxonomy
$labels = array(
'name' => _x( 'Sexes', 'shelter-dogs' ),
//etc.
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
'rewrite' => true,
'query_var' => true
);
register_taxonomy( 'dog_sex', array('shelter_dogs'), $args );
}
add_action('init', 'add_sexes', 100);
function add_sexes()
{
wp_insert_term(
'Male', // the term
'Sexes', // the taxonomy
array(
'slug' => 'Male'
)
);
}
I get the Sexes taxonomy, but no predefined values. Where's the problem?