Skip to content

Instantly share code, notes, and snippets.

@DanielSantoro
Created December 9, 2014 16:17
Show Gist options
  • Select an option

  • Save DanielSantoro/4092c289bbb474c19276 to your computer and use it in GitHub Desktop.

Select an option

Save DanielSantoro/4092c289bbb474c19276 to your computer and use it in GitHub Desktop.
Taxonomy to add Tag
// Register Custom Taxonomy
function custom_taxonomy() {
$labels = array(
'name' => _x( 'Tags', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Tag', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Tags', 'text_domain' ),
'all_items' => __( 'All Tags', 'text_domain' ),
'parent_item' => __( 'Parent Tags', 'text_domain' ),
'parent_item_colon' => __( 'Parent Tag:', 'text_domain' ),
'new_item_name' => __( 'New Tag Name', 'text_domain' ),
'add_new_item' => __( 'Add New Tag', 'text_domain' ),
'edit_item' => __( 'Edit Tag', 'text_domain' ),
'update_item' => __( 'Update Tag', 'text_domain' ),
'separate_items_with_commas' => __( 'Separate tags with commas', 'text_domain' ),
'search_items' => __( 'Search tags', 'text_domain' ),
'add_or_remove_items' => __( 'Add or Remove tags', 'text_domain' ),
'choose_from_most_used' => __( 'Choose from Most Used tags', 'text_domain' ),
'not_found' => __( 'Not Found', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( 'tags', array( 'post' ), $args );
}
// Hook into the 'init' action
add_action( 'init', 'custom_taxonomy', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment