Skip to content

Instantly share code, notes, and snippets.

@kaseybon
Created August 3, 2014 13:16
Show Gist options
  • Save kaseybon/1921369c1509036fa673 to your computer and use it in GitHub Desktop.
Save kaseybon/1921369c1509036fa673 to your computer and use it in GitHub Desktop.
WordPress - Share a custom taxonomy with multiple post types in place of a single $object_type.
add_action( 'init', 'create_my_taxonomies', 0 );
function create_my_taxonomies() {
register_taxonomy(
'type',
array('page, 'post', 'posttype1','posttype2'), //An array of post types that share this taxonomy
array(
'labels' => array(
'name' => 'Product Type',
'add_new_item' => 'Add New Product Type',
'new_item_name' => "New Product Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment