I am unable to add taxonomy to custom post types. But for same code if I add 'post' or 'page' it shows up fine. I can't pinpoint the problem.
Here is the code.
To register custom post type - working fine
register_taxonomy($key, 'SH_job_listings', $value); if i replace 'SH_job_listings' with post or page it works fine but not for custom post type i created.
class SH_job_post_class{
public function __construct(){
$this->register_job_Listings();
$this->add_taxonomies();
}
public function register_job_Listings(){
$args = array(
'labels' => array(
'name' => 'Job Listings',
'singular_name' => 'job Listing',
'add_new' => 'Add New Job',
'add_new_item' => 'Add New Job',
'edit_item' => 'Edit Jobs',
'new_item' => 'New Item',
'view_item' => 'View Item',
'search_item' => 'Search Jobs',
'not_found' => 'No Job Found',
'not_found_in_trash' => 'No Job Found In Trash'
),
'query_var' => 'job',
'rewrite' => array(
'slug' => 'jobs/'
),
'public' => true,
'menu_position' => 5,
//'menu_icon' => admin_url().
'supports' => array(
'title',
'thumbnail',
'editor',
'custom_fields'
)
);
// This function is actually registering post type
register_post_type('SH_job_listings', $args);
}
public function add_taxonomies(){
$taxonomies = array();
$taxonomies['job'] = array(
'hierarchical' => true,
'show_ui' => true,
'show_admin_column'=> true,
'query_var' => 'job_type',
'rewrite' => array(
'slug' => 'job/job_type'
),
'labels' => array(
'name' => 'job type',
'singular_name' => 'Job Type',
'edit_item' => 'Edit Job Type',
'update_item' => 'Update Job Type',
'add_new_item' => 'Add Job Type',
'new_item_name' => 'New Job Type',
'all_items' => 'All Job',
'popular_items' => 'Popular Job Types',
'search_items' => 'Search Job Types',
'separate_items_with_commas' => 'Separate Job Types with commas ',
'add_or_remove_items' => 'Add or Remove Job Type',
'choose_from_most_used' => 'Choose from most used Job Type'
)
);
$this->register_all_taxonomy($taxonomies);
}
public function register_all_taxonomy($all_taxonomy){
foreach($all_taxonomy as $key => $value){
register_taxonomy($key, 'SH_job_listings', $value);
}
}
}
add_action('init', function(){
new SH_job_post_class();
});