Skip to content

Instantly share code, notes, and snippets.

@Coop920
Created June 22, 2020 21:03
Show Gist options
  • Save Coop920/58b0a7b5fe1e5363e30e6a66440d216b to your computer and use it in GitHub Desktop.
Save Coop920/58b0a7b5fe1e5363e30e6a66440d216b to your computer and use it in GitHub Desktop.
function cptui_register_my_taxes_sector() {
/**
* Taxonomy: Sector.
*/
$labels = [
"name" => __( "Sector", "custom-post-type-ui" ),
"singular_name" => __( "Sector", "custom-post-type-ui" ),
];
$args = [
"label" => __( "Sector", "custom-post-type-ui" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => [ 'slug' => 'sector', 'with_front' => true, ],
"show_in_rest" => true,
"rest_base" => "sector",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => true,
'show_admin_column' => true,
];
register_taxonomy( "sector", [ "dt_articles" ], $args );
}
add_action( 'after_setup_theme', 'cptui_register_my_taxes_sector', 999 );
function add_categories_to_cpt(){
register_taxonomy_for_object_type('sector', 'dt_articles');
}
add_action('after_setup_theme','add_categories_to_cpt', 999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment