Skip to content

Instantly share code, notes, and snippets.

@pixelstorm
Forked from AnkanSoul/register_custom_post_type
Created January 23, 2019 05:37
Show Gist options
  • Save pixelstorm/1f88d8eecf1acaad31c8ef6a385a733d to your computer and use it in GitHub Desktop.
Save pixelstorm/1f88d8eecf1acaad31c8ef6a385a733d to your computer and use it in GitHub Desktop.
Register Custom Post Type
// Register Custom Post Type
function slider() {
$labels = array(
'name' => _x( 'Post Types', 'Post Type General Name', 'Post Types' ),
'singular_name' => _x( 'Post Type', 'Post Type Singular Name', 'Post Types' ),
'menu_name' => __( 'Post Types', 'Post Types' ),
'name_admin_bar' => __( 'Post Type', 'Post Types' ),
'archives' => __( 'Item Archives', 'Post Types' ),
'parent_item_colon' => __( 'Parent Item:', 'Post Types' ),
'all_items' => __( 'All Items', 'Post Types' ),
'add_new_item' => __( 'Add New Item', 'Post Types' ),
'add_new' => __( 'Add New', 'Post Types' ),
'new_item' => __( 'New Item', 'Post Types' ),
'edit_item' => __( 'Edit Item', 'Post Types' ),
'update_item' => __( 'Update Item', 'Post Types' ),
'view_item' => __( 'View Item', 'Post Types' ),
'search_items' => __( 'Search Item', 'Post Types' ),
'not_found' => __( 'Not found', 'Post Types' ),
'not_found_in_trash' => __( 'Not found in Trash', 'Post Types' ),
'featured_image' => __( 'Featured Image', 'Post Types' ),
'set_featured_image' => __( 'Set featured image', 'Post Types' ),
'remove_featured_image' => __( 'Remove featured image', 'Post Types' ),
'use_featured_image' => __( 'Use as featured image', 'Post Types' ),
'insert_into_item' => __( 'Insert into item', 'Post Types' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'Post Types' ),
'items_list' => __( 'Items list', 'Post Types' ),
'items_list_navigation' => __( 'Items list navigation', 'Post Types' ),
'filter_items_list' => __( 'Filter items list', 'Post Types' ),
);
$args = array(
'label' => __( 'Post Type', 'Post Types' ),
'description' => __( 'Post Type Description', 'Post Types' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-images-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' => 'page',
);
register_post_type( 'slider', $args );
}
add_action( 'init', 'slider', 0 );
==================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment