Skip to content

Instantly share code, notes, and snippets.

@sonnetmia
Created March 29, 2016 00:05
Show Gist options
  • Save sonnetmia/5e28cdcf4ef65345e494 to your computer and use it in GitHub Desktop.
Save sonnetmia/5e28cdcf4ef65345e494 to your computer and use it in GitHub Desktop.
// Register Custom Post Type
function custom_services_post_type() {
$labels = array(
'name' => _x( 'Services', 'Post Type General Name', 'custom_textdomain' ),
'singular_name' => _x( 'Service', 'Post Type Singular Name', 'custom_textdomain' ),
'menu_name' => __( 'Services', 'custom_textdomain' ),
'name_admin_bar' => __( 'Services', 'custom_textdomain' ),
'archives' => __( 'Item Archives', 'custom_textdomain' ),
'parent_item_colon' => __( 'Parent Item:', 'custom_textdomain' ),
'all_items' => __( 'All Items', 'custom_textdomain' ),
'add_new_item' => __( 'Add New Item', 'custom_textdomain' ),
'add_new' => __( 'Add New', 'custom_textdomain' ),
'new_item' => __( 'New Item', 'custom_textdomain' ),
'edit_item' => __( 'Edit Item', 'custom_textdomain' ),
'update_item' => __( 'Update Item', 'custom_textdomain' ),
'view_item' => __( 'View Item', 'custom_textdomain' ),
'search_items' => __( 'Search Item', 'custom_textdomain' ),
'not_found' => __( 'Not found', 'custom_textdomain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'custom_textdomain' ),
'featured_image' => __( 'Featured Image', 'custom_textdomain' ),
'set_featured_image' => __( 'Set featured image', 'custom_textdomain' ),
'remove_featured_image' => __( 'Remove featured image', 'custom_textdomain' ),
'use_featured_image' => __( 'Use as featured image', 'custom_textdomain' ),
'insert_into_item' => __( 'Insert into item', 'custom_textdomain' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'custom_textdomain' ),
'items_list' => __( 'Items list', 'custom_textdomain' ),
'items_list_navigation' => __( 'Items list navigation', 'custom_textdomain' ),
'filter_items_list' => __( 'Filter items list', 'custom_textdomain' ),
);
$rewrite = array(
'slug' => 'services',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => __( 'Service', 'custom_textdomain' ),
'description' => __( 'Service post type.', 'custom_textdomain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-slides',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'service', $args );
}
add_action( 'init', 'custom_services_post_type', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment