Skip to content

Instantly share code, notes, and snippets.

@siriokun
Last active December 20, 2017 03:52
Show Gist options
  • Save siriokun/265257d7844fae0f5eabf469b9b96cf9 to your computer and use it in GitHub Desktop.
Save siriokun/265257d7844fae0f5eabf469b9b96cf9 to your computer and use it in GitHub Desktop.
Artist post type with Topic taxonomy
// Topic Taxonomy
if ( ! function_exists( 'topic_taxonomy' ) ) {
// Register Topic Taxonomy
function topic_taxonomy() {
$labels = array(
'name' => _x( 'Topics', 'Taxonomy General Name', 'understrap' ),
'singular_name' => _x( 'Topic', 'Taxonomy Singular Name', 'understrap' ),
'menu_name' => __( 'Topics', 'understrap' ),
'all_items' => __( 'All topics', 'understrap' ),
'parent_item' => __( 'Parent Topic', 'understrap' ),
'parent_item_colon' => __( 'Parent Topic:', 'understrap' ),
'new_item_name' => __( 'New Topic Name', 'understrap' ),
'add_new_item' => __( 'Add New Topic', 'understrap' ),
'edit_item' => __( 'Edit Topic', 'understrap' ),
'update_item' => __( 'Update Topic', 'understrap' ),
'view_item' => __( 'View Topic', 'understrap' ),
'separate_items_with_commas' => __( 'Separate topics with commas', 'understrap' ),
'add_or_remove_items' => __( 'Add or remove topics', 'understrap' ),
'choose_from_most_used' => __( 'Choose from the most used', 'understrap' ),
'popular_items' => __( 'Popular Topics', 'understrap' ),
'search_items' => __( 'Search Topics', 'understrap' ),
'not_found' => __( 'Not Found', 'understrap' ),
'no_terms' => __( 'No topics', 'understrap' ),
'items_list' => __( 'Topics list', 'understrap' ),
'items_list_navigation' => __( 'Topics list navigation', 'understrap' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_rest' => true,
);
register_taxonomy( 'topic', array( 'artist' ), $args );
}
add_action( 'init', 'topic_taxonomy', 0 );
}
// Artist Post Type
if ( ! function_exists('artist_post_type') ) {
// Register Artist Post Type
function artist_post_type() {
$labels = array(
'name' => _x( 'Artists', 'Post Type General Name', 'understrap' ),
'singular_name' => _x( 'Artist', 'Post Type Singular Name', 'understrap' ),
'menu_name' => __( 'Artists', 'understrap' ),
'name_admin_bar' => __( 'Artist', 'understrap' ),
'archives' => __( 'Artist Archives', 'understrap' ),
'attributes' => __( 'Artist Attributes', 'understrap' ),
'parent_item_colon' => __( 'Parent Artist:', 'understrap' ),
'all_items' => __( 'All Artists', 'understrap' ),
'add_new_item' => __( 'Add New Artist', 'understrap' ),
'add_new' => __( 'Add New', 'understrap' ),
'new_item' => __( 'New Artist', 'understrap' ),
'edit_item' => __( 'Edit Artist', 'understrap' ),
'update_item' => __( 'Update Artist', 'understrap' ),
'view_item' => __( 'View Artist', 'understrap' ),
'view_items' => __( 'View Artists', 'understrap' ),
'search_items' => __( 'Search Artist', 'understrap' ),
'not_found' => __( 'Not found', 'understrap' ),
'not_found_in_trash' => __( 'Not found in Trash', 'understrap' ),
'featured_image' => __( 'Artist Photo', 'understrap' ),
'set_featured_image' => __( 'Set artist photo', 'understrap' ),
'remove_featured_image' => __( 'Remove artist photo', 'understrap' ),
'use_featured_image' => __( 'Use as artist photo', 'understrap' ),
'insert_into_item' => __( 'Insert into artist', 'understrap' ),
'uploaded_to_this_item' => __( 'Uploaded to this artist', 'understrap' ),
'items_list' => __( 'Artists list', 'understrap' ),
'items_list_navigation' => __( 'Artists list navigation', 'understrap' ),
'filter_items_list' => __( 'Filter artist list', 'understrap' ),
);
$args = array(
'label' => __( 'Artist', 'understrap' ),
'description' => __( 'Artist in Kelola.', 'understrap' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'taxonomies' => array( 'topic' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-customizer',
'show_in_admin_bar' => false,
'show_in_nav_menus' => false,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'show_in_rest' => false,
);
register_post_type( 'artist', $args );
}
add_action( 'init', 'artist_post_type', 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment