WordPress custom post type template. Source: https://woorkup.com/wordpress-custom-post-type/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', 'your_prefix_register_post_type' ); | |
function your_prefix_register_post_type() { | |
$args = [ | |
'label' => esc_html__( 'artists', 'text-domain' ), | |
'labels' => [ | |
'menu_name' => esc_html__( 'artists', 'your-textdomain' ), | |
'name_admin_bar' => esc_html__( 'Artist', 'your-textdomain' ), | |
'add_new' => esc_html__( 'Add artist', 'your-textdomain' ), | |
'add_new_item' => esc_html__( 'Add new artist', 'your-textdomain' ), | |
'new_item' => esc_html__( 'New artist', 'your-textdomain' ), | |
'edit_item' => esc_html__( 'Edit artist', 'your-textdomain' ), | |
'view_item' => esc_html__( 'View artist', 'your-textdomain' ), | |
'update_item' => esc_html__( 'View artist', 'your-textdomain' ), | |
'all_items' => esc_html__( 'All artists', 'your-textdomain' ), | |
'search_items' => esc_html__( 'Search artists', 'your-textdomain' ), | |
'parent_item_colon' => esc_html__( 'Parent artist', 'your-textdomain' ), | |
'not_found' => esc_html__( 'No artists found', 'your-textdomain' ), | |
'not_found_in_trash' => esc_html__( 'No artists found in Trash', 'your-textdomain' ), | |
'name' => esc_html__( 'artists', 'your-textdomain' ), | |
'singular_name' => esc_html__( 'artist', 'your-textdomain' ), | |
], | |
'public' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_nav_menus' => true, | |
'show_in_admin_bar' => true, | |
'show_in_rest' => true, | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'has_archive' => true, | |
'query_var' => true, | |
'can_export' => true, | |
'rewrite_no_front' => false, | |
'show_in_menu' => true, | |
'menu_position' => 5, | |
'menu_icon' => 'dashicons-format-audio', | |
'supports' => [ | |
'title', | |
'editor', | |
'thumbnail', | |
], | |
'rewrite' => true | |
]; | |
register_post_type( 'artist', $args ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment