Skip to content

Instantly share code, notes, and snippets.

@scofennell
Last active August 29, 2015 14:01
Show Gist options
  • Save scofennell/62a92b698d7e059e47c3 to your computer and use it in GitHub Desktop.
Save scofennell/62a92b698d7e059e47c3 to your computer and use it in GitHub Desktop.
Register WordPress tags for posts of the attachment post type, register other custom taxonomies as well
<?php
/**
* Register WordPress tags for posts of the attachment post type, register other custom taxonomies as well
*/
function sjf_deh_taxonomies() {
// allow tags to apply to posts of the attachment post_type
register_taxonomy_for_object_type( 'post_tag', 'attachment' );
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Skiers', 'taxonomy general name' ),
'singular_name' => _x( 'Skier', 'taxonomy singular name' ),
'search_items' => __( 'Search Skiers' ),
'all_items' => __( 'All Skiers' ),
'parent_item' => __( 'Parent Skier' ),
'parent_item_colon' => __( 'Parent Skier:' ),
'edit_item' => __( 'Edit Skier' ),
'update_item' => __( 'Update Skier' ),
'add_new_item' => __( 'Add New Skier' ),
'new_item_name' => __( 'New Skier Name' ),
'menu_name' => __( 'Skiers' ),
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'skiers' ),
);
register_taxonomy( 'skier', array( 'attachment' ), $args );
}
add_action( 'init', 'sjf_deh_taxonomies', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment