function yk_register_taxonomy() {
// add category
$labels = array(
'name' => _x( 'Attachment Categories', 'taxonomy general name'),
'singular_name' => _x( 'Attachment Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Attachment Categories' ),
'all_items' => __( 'All Attachment Categories' ),
'parent_item' => __( 'Parent Attachment Category' ),
'parent_item_colon' => __( 'Parent Attachment Category:' ),
'edit_item' => __( 'Edit Attachment Category' ),
'update_item' => __( 'Update Attachment Category' ),
'add_new_item' => __( 'Add New Attachment Category' ),
'new_item_name' => __( 'New Attachment Category Name' ),
'menu_name' => __( 'Attachment Category' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
);
register_taxonomy('attachment_category', 'attachment', $args);
// add tag
$labels = array(
'name' => _x( 'Attachment Tags', 'taxonomy general name' ),
'singular_name' => _x( 'Attachment Tag', 'taxonomy singular name' ),
'search_items' => __( 'Search Attachment Tags' ),
'all_items' => __( 'All Attachment Tags' ),
'parent_item' => __( 'Parent Attachment Tag' ),
'parent_item_colon' => __( 'Parent Attachment Tag:' ),
'edit_item' => __( 'Edit Attachment Tag' ),
'update_item' => __( 'Update Attachment Tag' ),
'add_new_item' => __( 'Add New Attachment Tag' ),
'new_item_name' => __( 'New Attachment Tag Name' ),
'menu_name' => __( 'Attachment Tags' ),
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
);
register_taxonomy('attachment_tag', 'attachment', $args);
}
add_action('init', 'yk_register_taxonomy');
プラグインを使うなら、Attachment Taxonomy Supportがおすすめです。
2012年6月4日月曜日
Wordpressのメディアにカテゴリーとタグを付ける
function.phpに以下を追加することで、メディア(attachment)にカテゴリーとタグを付けられます。
登録:
コメントの投稿 (Atom)
doesn't work for WP3.5
返信削除Thank you for your information.
削除