I have a plugin like this code and as you can see I have registered 3 taxonomies curriculum-levels
and curriculum-types
and curriculum-grades
like
register_taxonomy( 'curriculum-levels', array( 'curriculum-program' ), $args );
register_taxonomy( 'curriculum-types', array( 'curriculum-program' ), $args );
register_taxonomy( 'curriculum-grades', array( 'curriculum-program' ), $args );
and on custom post type I have
$args = array(
...
'taxonomies' => array( 'curriculum-levels', 'curriculum-grades', 'curriculum-types'),
...
);
but I am only getting the curriculum-grades
in the admin menu!
Can you please let me know why this is happening and how I can fix this?
flush_rewrite_rules( true );
function cpt_curriculum_level_taxonomy() {
$labels = array(
'name' => 'Curriculum Levels',
'singular_name' => 'Curriculum Level',
'menu_name' => 'Curriculum Levels',
'all_items' => 'All Curriculum Levels',
'parent_item' => 'Parent Curriculum Level',
'parent_item_colon' => 'Parent Curriculum Level:',
'new_item_name' => 'New Curriculum Level Name',
'add_new_item' => 'Add Curriculum New Level',
'edit_item' => 'Edit Curriculum Level',
'update_item' => 'Update Curriculum Level',
'view_item' => 'View Curriculum Level',
'separate_items_with_commas' => 'Separate Curriculum Levels with commas',
'add_or_remove_items' => 'Add or remove Curriculum Levels',
'choose_from_most_used' => 'Choose from the most used Curriculum Level',
'popular_items' => 'Popular Curriculum Level',
'search_items' => 'Search Curriculum Levels',
'not_found' => 'Not Found Curriculum Level',
'no_terms' => 'No Curriculum Levels',
'items_list' => 'Curriculum Levels list',
'items_list_navigation' => 'Curriculum Levels list navigation',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'rewrite' => array('slug' => 'levels', 'with_front' => true),
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( 'curriculum-levels', array( 'curriculum-program' ), $args );
}
add_action( 'init', ' cpt_curriculum_level_taxonomy', 0 );
function cpt_curriculum_type_taxonomy() {
$labels = array(
'name' => 'Curriculum Types',
'singular_name' => 'Curriculum Type',
'menu_name' => 'Curriculum Types',
'all_items' => 'All Curriculum Types',
'parent_item' => 'Parent Curriculum Type',
'parent_item_colon' => 'Parent Curriculum Type:',
'new_item_name' => 'New Curriculum Type Name',
'add_new_item' => 'Add New Curriculum Type',
'edit_item' => 'Edit Curriculum Type',
'update_item' => 'Update Curriculum Type',
'view_item' => 'View Curriculum Type',
'separate_items_with_commas' => 'Separate Curriculum Types with commas',
'add_or_remove_items' => 'Add or remove Curriculum Types',
'choose_from_most_used' => 'Choose from the most used Curriculum Type',
'popular_items' => 'Popular Curriculum Type',
'search_items' => 'Search Curriculum Types',
'not_found' => 'Not Found Curriculum Types',
'no_terms' => 'No Curriculum Types',
'items_list' => 'Curriculum Types list',
'items_list_navigation' => 'Curriculum Types list navigation',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'rewrite' => array('slug' => 'curriculums', 'with_front' => true),
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( 'curriculum-types', array( 'curriculum-program' ), $args );
}
add_action( 'init', 'cpt_curriculum_type_taxonomy()', 0 );
function cpt_curriculum_grade_taxonomy() {
$labels = array(
'name' => 'Curriculum Grades',
'singular_name' => 'Curriculum Grade',
'menu_name' => 'Curriculum Grades',
'all_items' => 'All Curriculum Grades',
'parent_item' => 'Parent Curriculum Grade',
'parent_item_colon' => 'Parent Curriculum Grade:',
'new_item_name' => 'New Curriculum Grade Name',
'add_new_item' => 'Add New Curriculum Grade',
'edit_item' => 'Edit Curriculum Grade',
'update_item' => 'Update Curriculum Grade',
'view_item' => 'View Curriculum Grade',
'separate_items_with_commas' => 'Separate Curriculum Grades with commas',
'add_or_remove_items' => 'Add or remove Curriculum Grades',
'choose_from_most_used' => 'Choose from the most used Curriculum Grade',
'popular_items' => 'Popular Curriculum Grade',
'search_items' => 'Search Curriculum Grades',
'not_found' => 'Not Found Curriculum Grades',
'no_terms' => 'No Curriculum Grades',
'items_list' => 'Curriculum Grades list',
'items_list_navigation' => 'Curriculum Grades list navigation',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'rewrite' => array('slug' => 'grades', 'with_front' => true),
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( 'curriculum-grades', array( 'curriculum-program' ), $args );
}
add_action( 'init', 'cpt_curriculum_grade_taxonomy', 0 );
function cpt_curriculum_program_cpt() {
$labels = array(
'name' => 'Curriculum Programs',
'singular_name' => 'Curriculum Program',
'menu_name' => 'Curriculum Programs',
'name_admin_bar' => 'Curriculum Program',
'archives' => 'Curriculum Program Archives',
'attributes' => 'Curriculum Program Attributes',
'parent_item_colon' => 'Parent Curriculum Program:',
'all_items' => 'All Curriculum Programs',
'add_new_item' => 'Add New Curriculum Program',
'add_new' => 'Add New Curriculum Program',
'new_item' => 'New Curriculum Program',
'edit_item' => 'Edit Curriculum Program',
'update_item' => 'Update Curriculum Program',
'view_item' => 'View Curriculum Program',
'view_items' => 'View Curriculum Program',
'search_items' => 'Search Curriculum Program',
'not_found' => 'Curriculum Program Not found',
'not_found_in_trash' => 'Curriculum Program Not found in Trash',
'featured_image' => 'Curriculum Program Featured Image',
'set_featured_image' => 'Set Curriculum Program Featured image',
'remove_featured_image' => 'Remove Curriculum Program Featured image',
'use_featured_image' => 'Use as Featured image',
'insert_into_item' => 'Insert into Curriculum Program',
'uploaded_to_this_item' => 'Uploaded to this Curriculum Program',
'items_list' => 'Curriculum Programs list',
'items_list_navigation' => 'Curriculum Programs list navigation',
'filter_items_list' => 'Filter Curriculum Programs list',
);
$args = array(
'label' => 'Curriculum Program',
'description' => 'Curriculum Program Post Type Description',
'labels' => $labels,
'supports' => array( 'title','editor','excerpt','thumbnail' ),
'taxonomies' => array( 'curriculum-levels', 'curriculum-grades', 'curriculum-types'),
'hierarchical' => true,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'curriculum-program', $args );
}
add_action( 'init', 'cpt_curriculum_program_cpt', 0 );
"why this is happening and how I can fix this?"
Because when you used the init
hook, you have passed incorrect calback function names
:
This:
add_action( 'init', ' cpt_curriculum_level_taxonomy', 0 );
Should be this (without the space in the beginning!):
add_action( 'init', 'cpt_curriculum_level_taxonomy');
And replace this one:
add_action( 'init', 'cpt_curriculum_type_taxonomy()', 0 );
with this (without the parentheses!):
add_action( 'init', 'cpt_curriculum_type_taxonomy');
And here's the result: