Skip to content

Instantly share code, notes, and snippets.

@hannit
Created October 20, 2016 04:22
Show Gist options
  • Save hannit/6f931b51407128918b9658ebc9950fa9 to your computer and use it in GitHub Desktop.
Save hannit/6f931b51407128918b9658ebc9950fa9 to your computer and use it in GitHub Desktop.
ADD CPT code
function nok_add_attarctions_cpt() {
$labels = array(
'name' => _x( 'Attractions', 'Post Type General Name', 'nok' ),
'singular_name' => _x( 'Attraction', 'Post Type Singular Name', 'nok' ),
'menu_name' => __( 'Attractions', 'nok' ),
'name_admin_bar' => __( 'Attraction', 'nok' ),
'archives' => __( 'Item Archives', 'nok' ),
'parent_item_colon' => __( 'Parent Item:', 'nok' ),
'all_items' => __( 'All Items', 'nok' ),
'add_new_item' => __( 'Add New Item', 'nok' ),
'add_new' => __( 'Add New', 'nok' ),
'new_item' => __( 'New Item', 'nok' ),
'edit_item' => __( 'Edit Item', 'nok' ),
'update_item' => __( 'Update Item', 'nok' ),
'view_item' => __( 'View Item', 'nok' ),
'search_items' => __( 'Search Item', 'nok' ),
'not_found' => __( 'Not found', 'nok' ),
'not_found_in_trash' => __( 'Not found in Trash', 'nok' ),
'featured_image' => __( 'Featured Image', 'nok' ),
'set_featured_image' => __( 'Set featured image', 'nok' ),
'remove_featured_image' => __( 'Remove featured image', 'nok' ),
'use_featured_image' => __( 'Use as featured image', 'nok' ),
'insert_into_item' => __( 'Insert into item', 'nok' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'nok' ),
'items_list' => __( 'Items list', 'nok' ),
'items_list_navigation' => __( 'Items list navigation', 'nok' ),
'filter_items_list' => __( 'Filter items list', 'nok' ),
);
$args = array(
'label' => __( 'Attraction', 'nok' ),
'description' => __( 'Attraction', 'nok' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-location-alt',
'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',
);
register_post_type( 'attraction', $args );
}
add_action( 'init', 'nok_add_attarctions_cpt', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment