Skip to content

Instantly share code, notes, and snippets.

@oddevan

oddevan/album_cpt.php Secret

Created Mar 15, 2021
Embed
What would you like to do?
<?php
function register_album_cpt() {
$labels = array(
'name' => _x( 'Albums', 'Post Type General Name', 'smolblog' ),
'singular_name' => _x( 'Album', 'Post Type Singular Name', 'smolblog' ),
'menu_name' => __( 'Albums', 'smolblog' ),
'name_admin_bar' => __( 'Album', 'smolblog' ),
'archives' => __( 'Album Archives', 'smolblog' ),
'attributes' => __( 'Album Attributes', 'smolblog' ),
'parent_item_colon' => __( 'Parent Album:', 'smolblog' ),
'all_items' => __( 'All Albums', 'smolblog' ),
'add_new_item' => __( 'Add New Album', 'smolblog' ),
'add_new' => __( 'Add New', 'smolblog' ),
'new_item' => __( 'New Album', 'smolblog' ),
'edit_item' => __( 'Edit Album', 'smolblog' ),
'update_item' => __( 'Update Album', 'smolblog' ),
'view_item' => __( 'View Album', 'smolblog' ),
'view_items' => __( 'View Albums', 'smolblog' ),
'search_items' => __( 'Search Album', 'smolblog' ),
'not_found' => __( 'Not found', 'smolblog' ),
'not_found_in_trash' => __( 'Not found in Trash', 'smolblog' ),
'featured_image' => __( 'Album Cover', 'smolblog' ),
'set_featured_image' => __( 'Set album cover', 'smolblog' ),
'remove_featured_image' => __( 'Remove album cover', 'smolblog' ),
'use_featured_image' => __( 'Use as album cover', 'smolblog' ),
'insert_into_item' => __( 'Insert into album', 'smolblog' ),
'uploaded_to_this_item' => __( 'Uploaded to this album', 'smolblog' ),
'items_list' => __( 'Albums list', 'smolblog' ),
'items_list_navigation' => __( 'Albums list navigation', 'smolblog' ),
'filter_items_list' => __( 'Filter albums list', 'smolblog' ),
);
$args = array(
'label' => __( 'Album', 'smolblog' ),
'description' => __( 'A musical release', 'smolblog' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
'taxonomies' => array( 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-audio',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
'show_in_graphql' => true,
'graphql_single_name' => 'album',
'graphql_plural_name' => 'albums',
);
register_post_type( 'album', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment