Create custom post type in WordPress
Last Updated :
22 Mar, 2022
The WordPress software is very handy and flexible to use as it allows not only the use of different posts and webpages but it also allows the use of the customized created post types with different types of users.
The customizable post types in the WordPress software allow the user to normal and regular website that makes use of WordPress to turn it into a completely new type of website which has the capabilities to become a content management website. It can create a lot of new customizable options for the users to outcast their different items on their website. WordPress allows different types of customizable post types like – a blog post, distinct media attachments, posts revision algorithms, and a new navigation menu for the websites. This customizable post type gets saved in the WordPress software for future use purposes.
In this article, we will learn how to create a custom post type in WordPress and it will work.
The functions which are used to create the customized post types include the init function which is created by using the add_action(), whereas while taking the arguments we use the register_post_type().
Types of Custom post types: The different types of customizable posts in WordPress is as follows:
- Posts
- Pages
- Navigation menu of the website
- Attachments media on websites
- Customized CSS
- Revisions
- Comments
- Page attributes
- Labels
- Public
- ChangeSets
Customizable posts allow the users to create a new WordPress project on their website with the recently saved version that enhances the overall look and feel of the posts on that website.
Syntax:
/* Start */
function create_post() {
register_post_type( 'item',
array(
'labels' => array(
'name' => __( 'item' ),
'title_name' => __( 'Item' )
),
'public' => true,
'post_archive' => false,
'rewrite' => array('slug' => 'item'),
)
);
}
add_action( 'init', 'create_post' );
/* Stop */
How to create a Custom Post type: We can create a custom post type for the WordPress software by the following steps:
Write the following code in the terminal window of the admin bar of the WordPress software to run the program. This will initiate the function.php file in the terminal on the execution.
There are basically three types of customized post-type functions for the WordPress software.
- $args: It is responsible for calculating and processing the slug option in the items located in the navigation menu of the website. It stands for argument variable which is used to denote the arrays. It stores the data like keys and values inside the array to store the custom post types.
- $labels: It is responsible for identifying that a particular post type item is only limited to the administrator of the WordPress document only. It represents the first array inside the argument variable of the custom posts.
- $supports: It is responsible for checking that a particular post type in WordPress is compatible with all types of device form factors like a phone and a PC and it contains all the essential features on that website. The supported variable enables the custom posts type in WordPress to have editor-like features.
Steps to create new custom types:
Step 1: Create a new customized post type with WordPress using a PHP program using a Customized post type with the help of its UI.
Step 2: Select all the options for setting the fields and post types using the ACF programs.
Step 3: Choose an example item on which the newly created customized post types will be added and applied to the content on WordPress.
Step 4: Usage of the dynamic content in the customized posts will result in storing and saving these custom posts on the WordPress server. Now, the customized posts are ready to be published to the server.

Create new post type in WordPress
Algorithm for creating Custom Post using Arg, Label, and Support:
The given below program will allow the users to create and customize new options for the post types in the WordPress along with various other options like customizing title, editor, thumbnail, adding new items, search items, and using the arg, label, and support functions in the program for custom post types. Enter the program in the Custom Articles tab bar and then it will show the option for the terminal window, after the given program gets executed it will create a new customized post type according to the user’s needs.

Enter the given program in the terminal window of the Custom articles tab
/* start */
function create_post() {
$supports = array(
'title',
'editor',
'author',
'thumbnail',
'comments',
'revisions',
'post-formats',
);
$labels = array(
'name' => _x('item', 'plural'),
'title_name' => _x('item', 'singular'),
'menu_name' => _x('item', 'admin menu'),
'name_admin' => _x('item', 'admin bar'),
'add_new' => _x('Add New', 'add new'),
'add_new_item' => __('Add New news'),
'new_item' => __('New item'),
'edit_item' => __('Edit item'),
'view_item' => __('View item'),
'all_items' => __('All item'),
'search_items' => __('Search item'),
'not_found' => __('No item found.'),
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => true,
'query_var' => true,
'rewrite' => array('slug' => 'item'),
);
register_post_type('item', $args);
}
add_action('init', 'create_post');
/* Stop */
Similar Reads
WordPress Create custom REST endpoint
WordPress, as a powerful content management system (CMS), allows developers to create custom REST endpoints. These endpoints enable communication between external applications and your WordPress site, making it possible to retrieve or manipulate data programmatically. WordPress gives various functio
2 min read
7 Best Custom Post Type Plugins for WordPress
Creating custom post types (CPTs) in WordPress allows you to make your website's content fit your specific needs, whether you're running a blog, an e-commerce site, or a portfolio. Custom post-type plugins simplify this process, making it easy even for beginners to extend the functionality of their
3 min read
How to Create Custom Taxonomies in WordPress ?
Taxonomies in WordPress are a way of grouping and organizing content. While WordPress comes with built-in taxonomies like categories and tags, sometimes you may need to create custom taxonomies to better organize your content. In this article, we'll explore how to create custom taxonomies in WordPre
3 min read
How to Create Custom Permalinks in WordPress?
Permalinks in WordPress are the permanent URLs of the posts, pages, and other content on your website. By default, WordPress uses a standard permalink structure that includes the post ID and the post title. However, you can customize your permalinks to make them more user-friendly and SEO-friendly.
2 min read
How to Create WordPress Custom Widgets?
Creating custom widgets in WordPress can significantly enhance your website's functionality by allowing you to add specific features and content to your sidebar or other widgetized areas. This article will guide you through the process of creating custom widgets, explaining different approaches and
5 min read
How to Create Custom WordPress Single-Post Templates?
In WordPress, a "post" refers to a type of content that is typically used for blog entries or articles. Posts are organized chronologically and can be categorized and tagged for better organization and navigation. They are a fundamental part of a WordPress site, especially for blogs, news sites, and
2 min read
How to Create HTML Sitemap in WordPress ?
Creating an HTML sitemap in WordPress can significantly improve your site's navigation and SEO. HTML sitemaps provide a user-friendly way to list all the pages of your website in a structured manner. This helps visitors find content easily and search engines to crawl your site more efficiently. What
3 min read
How to create static front page in WordPress ?
Creating a static front page in WordPress can give your website a professional and customized look. Unlike the default setting where your latest posts are displayed on the homepage, a static front page allows you to showcase specific content that remains constant. This is particularly useful for bus
4 min read
How to create demo website in WordPress ?
A demo website is a website that contains content that is relevant to the work you do and shows off your skills. A demo website can be created in WordPress using several different themes. Themes allow you to customize the layout and design of your site, with many websites providing both free and pai
7 min read
How to Create WordPress Plugin from Scratch ?
Creating a WordPress plugin from scratch might seem tough, but it's an essential skill for customizing and extending the functionality of your WordPress site. This article will walk you through the steps of creating a simple plugin. What is a WordPress Plugin?A WordPress plugin is a piece of softwar
5 min read