Skip to content

Instantly share code, notes, and snippets.

@carolinan
Created March 18, 2024 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carolinan/113c529165d7b88b331aae39d5587c6f to your computer and use it in GitHub Desktop.
Save carolinan/113c529165d7b88b331aae39d5587c6f to your computer and use it in GitHub Desktop.
Register taxonomy
// Add Level taxonomy to pages.
function fsecom_register_taxonomy_level() {
$labels = array(
'name' => _x( 'Level', 'taxonomy general name' ),
'singular_name' => _x( 'Level', 'taxonomy singular name' ),
'search_items' => __( 'Search Levels' ),
'all_items' => __( 'All Levels' ),
'edit_item' => __( 'Edit Level' ),
'update_item' => __( 'Update Level' ),
'add_new_item' => __( 'Add New Level' ),
'new_item_name' => __( 'New Level Name' ),
'menu_name' => __( 'Levels' ),
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_rest' => true,
);
register_taxonomy( 'level', [ 'page' ], $args );
}
add_action( 'init', 'fsecom_register_taxonomy_level' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment