Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Post Type and Taxonomy registration example for WordPress
<?php
/* Register Custom Post Type */
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'case-study',
array(
'labels' => array(
'name' => __( 'Case Studies' ),
'singular_name' => __( 'Case Study' )
),
'public' => true,
'has_archive' => true,
'show_in_admin_bar' => true,
'show_ui' => true,
)
);
}
/* Register Custom Taxonomy */
add_action( 'init', 'create_case_study_taxonomies', 0 );
function create_case_study_taxonomies()
{
register_taxonomy('case-study-category','case-study',array(
'hierarchical' => true,
'label' => 'Category',
'query_var' => true,
'rewrite' => array( 'slug' => 'category' ),
));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.