I'm trying to set up a site with a custom post type called 'Village Life', with a matching taxonomy called 'village'. Here's the code I used to register my post type -
function create_post_type() {
register_post_type('Village',
array(
'labels' => array(
'name'=> __('Villages'),
'singular_name'=> __('Village')
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => 'village-life'
)
)
);
}
It works fine, and it shows up in the dashboard. When a user creates a 'Village Life' post, I'd like to add the title of the post (as a term) to the taxonomy 'village', so there will be a controlled list of 'villages' (There should be no other way for a user to add a village to the taxonomy, without creating a "Village Life' post. Here's the function for that -
function create_post_type() {
register_post_type('Village',
array(
'labels' => array(
'name'=> __('Villages'),
'singular_name'=> __('Village')
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => 'village-life'
)
)
);
}
And here are the hooks I'm using -
add_action('init','create_post_type');
add_action('edit_post', 'create_village_callback');
add_action('save_post ', 'create_village_callback');
add_action('publish_post ', 'create_village_callback');
add_action('edit_page_form ', 'create_village_callback');
None of them seem to work. I've gotten the echo statement to show up on autodraft saving, but it doesn't run (or seem to run) when I click publish. Also, the titles are not showing up in my taxonomy. Anyone able to see what I'm doing wrong? I appreciate the help in advance!