We only get three built-in content types at the backend when we install WordPress, i.e., posts, pages, and media. However, today WordPress has become quite flexible and advanced.
The approach to adding more post types also has expanded. The diversified usage demands more content types because posts, pages, and media are not enough, and here is where WordPress custom post type comes in handy.
What Is a WordPress Custom Post Type?
Custom post types are used to convert a regular WordPress website into a content management system. As the name suggests, you can use custom post types to create various content types for your website.
Besides that, one can find several post types available by default in WordPress installation, including:
- Post – blog post
- Page – static page
- Attachment – attached media
- Revision – post revision
- Navigation Menu – nav menu
- WordPress supports an unlimited number of Custom Post Types. You can create your custom posts and call them up wherever you want.
- For example, if you run a News website and want to add a custom post type titled “News.” Once created, the news post-type would have its own menu in the WordPress dashboard admin area. Additionally, you can create multiple post types, such as Movies, Portfolios, etc.
What Is a WordPress Custom Post Type?
Custom post types are used to convert a regular WordPress website into a content management system. As the name suggests, you can use custom post types to create various content types for your website.
Besides that, one can find several post types available by default in WordPress installation, including:
- Post – blog post
- Page – static page
- Attachment – attached media
- Revision – post revision
- Navigation Menu – nav menu
WordPress supports an unlimited number of Custom Post Types. You can create your custom posts and call them up wherever you want.
For example, if you run a News website and want to add a custom post type titled “News.” Once created, the news post-type would have its own menu in the WordPress dashboard admin area. Additionally, you can create multiple post types, such as Movies, Portfolios, etc.
Follow the steps below to create a custom post type on a WordPress website:
- Navigate to the function.php file from your WordPress theme directory
- Add the following code to the function.php file
- /* Custom Post Type Start */
- function create_posttype() {
- register_post_type( 'news',
- // CPT Options
- array(
- 'labels' => array(
- 'name' => __( 'news' ),
- 'singular_name' => __( 'News' )
- ),
- 'public' => true,
- 'has_archive' => false,
- 'rewrite' => array('slug' => 'news'),
- )
- );
- }
- // Hooking up our function to theme setup
- add_action( 'init', 'create_posttype' );
- /* Custom Post Type End */
- Once you’ve added the code, the News post-type will automatically appear in the admin area