Skip to content

Instantly share code, notes, and snippets.

@mcfarhat
Created December 2, 2017 10:23
Show Gist options
  • Save mcfarhat/212c29a562ae18aa2a7a114b6bf2a2ed to your computer and use it in GitHub Desktop.
Save mcfarhat/212c29a562ae18aa2a7a114b6bf2a2ed to your computer and use it in GitHub Desktop.
/* Creating the car custom post type */
if ( ! function_exists('gk_create_car_type') ) {
// Register Car Custom Post Type
function gk_create_car_type() {
$labels = array(
'name' => _x( 'Cars', 'Post Type General Name', 'car' ),
'singular_name' => _x( 'Car', 'Post Type Singular Name', 'car' ),
'menu_name' => __( 'Cars', 'car' ),
'name_admin_bar' => __( 'Car', 'car' ),
'archives' => __( 'Car Archives', 'car' ),
'parent_item_colon' => __( 'Parent Car:', 'car' ),
'all_items' => __( 'All Cars', 'car' ),
'add_new_item' => __( 'Add New Car', 'car' ),
'add_new' => __( 'Add Car', 'car' ),
'new_item' => __( 'New Car', 'car' ),
'edit_item' => __( 'Edit Car', 'car' ),
'update_item' => __( 'Update Car', 'car' ),
'view_item' => __( 'View Car', 'car' ),
'search_items' => __( 'Search Car', 'car' ),
'not_found' => __( 'Not found', 'car' ),
'not_found_in_trash' => __( 'Not found in Trash', 'car' ),
'featured_image' => __( 'Featured Image', 'car' ),
'set_featured_image' => __( 'Set featured image', 'car' ),
'remove_featured_image' => __( 'Remove featured image', 'car' ),
'use_featured_image' => __( 'Use as featured image', 'car' ),
'insert_into_item' => __( 'Insert into item', 'car' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'car' ),
'items_list' => __( 'Cars list', 'car' ),
'items_list_navigation' => __( 'Cars list navigation', 'car' ),
'filter_items_list' => __( 'Filter Cars list', 'car' ),
);
$args = array(
'label' => __( 'Car', 'car' ),
'description' => __( 'Car Type', 'car' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail' ),//, 'custom-fields',
'taxonomies' => array( 'category', 'post_tag'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 65,
'show_in_admin_bar' => true,
'show_in_nav_menus' => false,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type( 'car', $args );
}
add_action( 'init', 'gk_create_car_type', 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment