I'm not sure if this possible, but I'd like to be able to show my taxonomies within the admin area of my custom post type so that WordPress users can sort the posts my e.g. subject.
Here's my code for my custom post type and taxonomies
register_post_type( 'courses',
array(
'labels' => array(
'name' => __( 'Courses' ),
'singular_name' => __( 'Course' )
),
'public' => true,
'has_archive' => false,
'rewrite' => array('slug' => 'courses/%subject%'),
)
);
}
function themes_taxonomy() {
register_taxonomy(
'campuses', // The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
'courses', // post type name
array(
'hierarchical' => true,
'label' => 'Campuses', // display name
'query_var' => true,
'rewrite' => array(
'slug' => 'campus', // This controls the base slug that will display before each term
'with_front' => false // Don't display the category base before
)
)
);
register_taxonomy(
'ages', // The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
'courses', // post type name
array(
'hierarchical' => true,
'label' => 'Ages', // display name
'query_var' => true,
'rewrite' => array(
'slug' => 'ages', // This controls the base slug that will display before each term
'with_front' => false // Don't display the category base before
)
)
);
register_taxonomy(
'subject', // The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
'courses', // post type name
array(
'hierarchical' => true,
'label' => 'Subjects', // display name
'query_var' => true,
'rewrite' => array(
'slug' => 'subjects', // This controls the base slug that will display before each term
'with_front' => false // Don't display the category base before
)
)
);
} add_action( 'init', 'themes_taxonomy');