WordPress Custom post type feature is a time saving of developer while it come to developing a CMS site in WordPress. By default WordPress has five post types (posts and pages are the most popular), organized using built-in taxonomies like categories and tags. However, you can extend the functionality of WordPress and display different types of content according to your own rules by creating custom post types and taxonomies.
<?php function create_post_type() { $labels = array( 'name' => 'Projects', 'singular_name' => 'Project', 'menu_name' => 'Projects', 'name_admin_bar' => 'Project', 'add_new' => 'Add New', 'add_new_item' => 'Add New Project', 'new_item' => 'New Project', 'edit_item' => 'Edit Project', 'view_item' => 'View Project', 'all_items' => 'All Projects', 'search_items' => 'Search Projects', 'parent_item_colon' => 'Parent Project', 'not_found' => 'No Projects Found', 'not_found_in_trash' => 'No Projects Found in Trash' ); $args = array( 'labels' => $labels, 'public' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'show_in_menu' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-admin-appearance', 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ), 'has_archive' => true, 'rewrite' => array( 'slug' => 'projects' ), 'query_var' => true ); register_post_type( 'sm_project', $args ); } ?>
Naming Best Practices
While it is convenient to use a simple custom post type identifier like product which is consistent with the identifiers of the default post types (post, page, revision, attachment and nav_menu_item), it is better if you prefix your identifier with a short namespace that identifies your plugin, theme or website that implements the custom post type.
For example:
acme_product or aw_product for products post type used by a hypothetical ACMEWidgets.com website.
eightfold_product or eft_product for products post type provided by a hypothetical EightFold theme.
ai1m_product for products post type provided by a hypothetical All-in-One Merchant plugin.