How to Create Custom Post Type in WordPress (Easy Guide) (2024)

How to Create Custom Post Type in WordPress (Easy Guide) (1)

When you install WordPress, you’re initially provided with three built-in content types: posts, pages, and media. However, as the diversity of usage increases, these standard options may not meet requirements for everyone’s needs.

To address this issue, WordPress has evolved to become more flexible and advanced. That’s where WordPress custom post types come into play. They offer a way to create and manage content that goes beyond the standard posts, pages, and media.

In this blog post, I’ll guide you through creating and managing custom post types in WordPress, from understanding their importance to troubleshooting common issues. You can easily follow these steps if you are using managed WordPress hosting servers from Cloudways. Let’s get started to take your content creation to the next level!

  • What Are Custom Post Types?
  • Default vs Custom Post Types
  • Why Use Custom Post Types?
  • Create Custom Post Types in WordPress
  • Add a New WordPress Custom Post Type
  • Create a Template and Fetching List
  • Add Menu for Custom Post Type
  • Create a Detail Page for Custom Post Type
  • Customize Your Custom Post Types
  • Display Custom Post Type on your Site
  • Troubleshooting Common Issues

What Are Custom Post Types?

Custom post types in WordPress can turn your website into a powerful CMS. They allow you to create different types of content beyond the standard posts, pages, and media. There’s no limit to the number of custom post types you can create.

For instance, if you run a News website, you can create a custom post type titled “News”. This new type will have its own dedicated section in the WordPress dashboard admin area. You can create as many post types as needed, such as “Movies”, “Portfolios”, and more.

If you’re using WordPress 5.x, a detailed guide is available on enabling the Gutenberg Editor for your custom post type. For more information on other post types in WordPress, refer to the Custom Post Types codex documentation.

Looking to smoothly implement custom post types on your site?

Experience effortless WordPress customization with Cloudways WordPress Hosting.

TRY NOW

Default vs Custom Post Types

Both default and custom post types have their own uses and can coexist on your WordPress site to provide a rich and diverse content experience. Look look at their differences!

Default Post TypesCustom Post Types
AvailabilityAvailable by default when you install WordPress.Need to be created manually or with a plugin.
TypesPosts, Pages, and Media.Unlimited, based on your needs (e.g., News, Movies, Portfolios).
FlexibilityLimited to the built-in options.Highly flexible, can be customized to fit your specific needs.
UsageIdeal for standard blog posts, static pages, and media files.Ideal for specialized content that doesn’t fit into the default post types.

Why Use Custom Post Types?

Here are a few more reasons why you should use custom post types in WordPress:

  1. They help keep your website tidy by separating different kinds of content.
  2. They make it easier for visitors to find what they’re looking for on your site.
  3. They let you add special features to certain posts, like review scores for book reviews.
  4. They can help your site show up higher in search engine results.
  5. They make it easier to create consistent, structured content, especially when multiple people are adding content to your site.

Create Custom Post Types in WordPress

Creating custom post types in WordPress can be done using two different methods: via plugin or manually. Each method caters to different user skills and preferences. Let’s look at them step by step.

Method 1: Create a Custom Post via Plugin

You can create a WordPress custom post type easily using the right plugin. For this article, I’ll use the Custom Post Type UI plugin to guide you through the process.

Step 1: Install and Activate the Plugin

The first step is to install and activate the plugin.

  1. Go to your WordPress Dashboard;
  2. Select Plugins Add New;
  3. Search for the ‘Custom Post Type UI’ plugin;
  4. Install and Activate the plugin.

How to Create Custom Post Type in WordPress (Easy Guide) (2)

Step 2: Set up and Configure the Plugin

Once activated, you’ll find a new menu item in the dashboard called CPT UI.

  • Click on CPT UI → Add/Edit Post Types to create a new custom post type;
  • Fill in the Post Type Slug, which is a required field and must be unique (usually a lowercase string with no spaces);
  • Add the plural and singular names for your custom post type as they will appear in the dashboard;
  • Click on the Add post type button.

How to Create Custom Post Type in WordPress (Easy Guide) (3)

Step 3: Use Your Custom Post Type

Your new custom post type should now be visible in the WordPress Dashboard. You can start adding new content by clicking on the menu item for your custom post type.

How to Create Custom Post Type in WordPress (Easy Guide) (4)

  • Go to Add New and customize your custom post type.

How to Create Custom Post Type in WordPress (Easy Guide) (5)

  • I will add a quote and contact form on my news page;
  • To do that click on the + (plus) sign;
  • Select Pull Quote.

How to Create Custom Post Type in WordPress (Easy Guide) (6)

  • Select Contact Form 7.

How to Create Custom Post Type in WordPress (Easy Guide) (7)

  • Click on the Publish button.
  • Here’s what the final news page looks like.

How to Create Custom Post Type in WordPress (Easy Guide) (8)

Method 2: Create WordPress Custom Post Manually

Now, let’s follow these steps to create a custom post type manually on your WordPress site:

  1. Navigate to the function.php file on your theme directory;
  2. Add the following code to the function.php file.
/* Custom Post Type Start */function create_posttype() {register_post_type( 'news',// CPT Optionsarray('labels' => array('name' => __( 'news' ),'singular_name' => __( 'News' )),'public' => true,'has_archive' => false,'rewrite' => array('slug' => 'news'),));}// Hooking up our function to theme setupadd_action( 'init', 'create_posttype' );/* Custom Post Type End */
  • Once you’ve added the code, the News post type will automatically appear in your WordPress menu.

How to Create Custom Post Type in WordPress (Easy Guide) (9)

  • When creating custom post types, it is necessary to use init for the hook in add_action(), and the register_post_type() function will take the arguments
/*Custom Post type start*/function cw_post_type_news() {$supports = array('title', // post title'editor', // post content'author', // post author'thumbnail', // featured images'excerpt', // post excerpt'custom-fields', // custom fields'comments', // post comments'revisions', // post revisions'post-formats', // post formats);$labels = array('name' => _x('news', 'plural'),'singular_name' => _x('news', 'singular'),'menu_name' => _x('news', 'admin menu'),'name_admin_bar' => _x('news', 'admin bar'),'add_new' => _x('Add New', 'add new'),'add_new_item' => __('Add New news'),'new_item' => __('New news'),'edit_item' => __('Edit news'),'view_item' => __('View news'),'all_items' => __('All news'),'search_items' => __('Search news'),'not_found' => __('No news found.'),);$args = array('supports' => $supports,'labels' => $labels,'public' => true,'query_var' => true,'rewrite' => array('slug' => 'news'),'has_archive' => true,'hierarchical' => false,);register_post_type('news', $args);}add_action('init', 'cw_post_type_news');/*Custom Post type end*/

Here’s the code explanation:

  • $supports: Specifies that the post type is compatible and supports all essential features.
  • $labels: Specifies that the post type is referred correctly to the admin area.
  • $args: Specifies a permalink slug of the news and a menu position located just beneath the Posts menu.

Here’s the look at before and after adding custom post features to your WordPress site.

How to Create Custom Post Type in WordPress (Easy Guide) (10)

– Before adding features

How to Create Custom Post Type in WordPress (Easy Guide) (11)

– After adding features

The steps we’ve covered so far have shown you how to register custom post types to the backend of any WordPress theme. Now, let’s move forward and learn how to add a custom post to your WordPress site.

Add a New WordPress Custom Post Type

You can add a new custom post on your WordPress site by following these steps:

  • Click registered custom post type, which in our case is News;
  • Click Add New;
  • Type the title and body of your post;
  • Type the excerpt and set a featured image;
  • Click on the Publish button to take the new custom post live.

How to Create Custom Post Type in WordPress (Easy Guide) (12)

Create a Template and Fetching List

Next, it’s time to create a template and fetch a list. For this, you’ll need to create a new file named template-news.php.

  • Place the newly created file in your theme folder;
  • Add the following code to the file.
<?php/*Template Name: News*/get_header();query_posts(array('post_type' => 'news')); ?><?phpwhile (have_posts()) : the_post(); ?><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2><p><?php the_excerpt(); ?></p><?php endwhile;get_footer();?>

Select a Template

  • Go to your WordPress Dashboard;
  • Click PagesAdd New;
  • Create a new page named News;
  • Click Page Attributes on the right side and access the drop-down menu under Template;
  • Select the new template News;
  • Click on the Update button to set your template.

Refer to the image below for the visual representation of the above steps:

How to Create Custom Post Type in WordPress (Easy Guide) (13)

The image below represents the final display of your listing page:

How to Create Custom Post Type in WordPress (Easy Guide) (14)

Add Menu for Custom Post Type

Add your custom post type as a part of the Menu options on your WordPress site by following these steps:

  • Go to your WordPress Dashboard;
  • Navigate to AppearanceMenus;
  • Add the News page to your main menu to display a navigational link to our newly created WordPress custom post type, News;

For further reference, check out the image below.

How to Create Custom Post Type in WordPress (Easy Guide) (15)

And this is how your website will look on the front end. Check out the image below:

How to Create Custom Post Type in WordPress (Easy Guide) (16)

Accelerate Your Website With Cloudways Managed WordPress Hosting

Create custom post types with complete freedom.

Try Now

Create a Detail Page for Custom Post Type

Create a detail page for custom post type by following the steps below.

  • Add a new file called single-news.php (located in your WordPress theme);
  • Add the following code to the file.
<?phpget_header();/* Start the Loop */while (have_posts()) : the_post();get_template_part('template-parts/post/content', get_post_format());endwhile; // End of the loop.get_footer();?>

Now it’s time to see what your detail page looks like:

How to Create Custom Post Type in WordPress (Easy Guide) (17)

Customize Your Custom Post Types

Customizing your custom post types using the CPT UI plugin is way simpler. Here’s how you can do it:

  • Go to CPT UIAdd/Edit Post Types;
  • You will see all the settings. Play with those as per your needs;
  • For example, if you want to change the labels or add a new item, go to the additional labels and set them up.

How to Create Custom Post Type in WordPress (Easy Guide) (18)

  • Similarly, play with other settings to customize it as you please.

Display Custom Post Type on your site

You can display custom post types on your site using the default archive template.

  • Go to Appearance → Menu;
  • Under the custom link, add your URL and Link Text.

How to Create Custom Post Type in WordPress (Easy Guide) (19)

  • Save the menu.
  • Reload the page, and you will see news on the top of your site’s front end.

How to Create Custom Post Type in WordPress (Easy Guide) (20)

Troubleshooting Common Issues

When working with Custom Post Types (CPTs) in WordPress, you might encounter a few common issues. Here are the two most common issues that might show up and the ways to solve them.

1. Custom Post Type Not Showing up

Sometimes, you have added the custom post type, but it doesn’t appear. The possible reasons for this can be:

  • Incorrect code.
  • Plugin conflict.

Solution

  • You need to review the code to ensure that the code is right. Take expert help to do that.
  • Try deactivating the plugins to check that none conflicts with the custom post-type plugin you’re using.

2. Problems With Permalinks

If you’re experiencing issues with permalinks related to your CPT, such as 404 errors or incorrect routing, here’s how you can fix it.

Solution

  • Go to Settings → Permalinks;
  • Click on the Save Changes button.

How to Create Custom Post Type in WordPress (Easy Guide) (21)

Also, sometimes a CPT might have the same slug as an existing page, causing conflicts. Ensure that your CPT slug is unique.

Future-Proof Your Businesses with Autonomous!

Ensure your small business is ready for whatever comes next with Cloudways Autonomous. Stay ahead of the curve with advanced scalability and cutting-edge technology.

Start Today

Summary

You have now learned how to create a custom post type in WordPress, which is quite complex but can be easily done by following the steps mentioned in this blog. You can use custom post types with our WordPress hosting.

Check out our other blog posts for more helpful guides on managing your WordPress site, such as reducing WordPress load times. If you have any queries or suggestions regarding the blog, feel free to comment below.

Frequently Asked Questions

Q: What is custom post type in WordPress?

A: A custom post type in WordPress is a feature that allows users to define their own content types beyond the default posts and pages. It enables the creation of unique content structures tailored to specific needs.

Q: What is custom post type in WordPress related posts?

A: Custom post types in WordPress related posts refer to content types created by users to organize and display specific types of content. These can include products, portfolio items, events, and more, enhancing website organization and user experience.

Q: How do I create a custom post type category in WordPress?

A: You can create a custom post type category in WordPress by using a plugin or custom code. Follow the steps below if you want to use a plugin:

  • Go to your WordPress dashboard.
  • Download a plugin like Custom Post Type UI.
  • Install and activate it.
  • Navigate to the plugin settings in your WordPress dashboard.
  • Register a new taxonomy with the necessary details.
  • Associate the taxonomy with your custom post type.
  • Save your settings.
  • Verify functionality and make any necessary modifications.
  • Start using your custom post type category to organize your content.

Q: Is custom post type UI free?

A: Yes, Custom Post Type UI is a free plugin for WordPress that simplifies the process of creating and managing custom post types and taxonomies. It provides a user-friendly interface for defining and configuring custom content types without the need for coding knowledge.

Go to your WordPress dashboard.Download a plugin like Custom Post Type UI.Install and activate it.Navigate to the plugin settings in your WordPress dashboard.Register a new taxonomy with the necessary details.Associate the taxonomy with your custom post type.Save your settings.Verify functionality and make any necessary modifications.Start using your custom post type category to organize your content." } },{ "@type": "Question", "name": "Is custom post type UI free?", "acceptedAnswer": { "@type": "Answer", "text": "Yes, Custom Post Type UI is a free plugin for WordPress that simplifies the process of creating and managing custom post types and taxonomies. It provides a user-friendly interface for defining and configuring custom content types without the need for coding knowledge." } }]}

Share your opinion in the comment section. COMMENT NOW

Share This Article

Save EXTRA With the Hosting Pricing Calculator!

Get a detailed cost comparison of the leading hosting providers for FREE. Find the optimum hosting solution that optimizes your savings.

Calculate Now

How to Create Custom Post Type in WordPress (Easy Guide) (22)

Sarim Javaid

Sarim Javaid is a Digital Content Producer at Cloudways. He has a habit of penning down his random thoughts and giving words and meaning to the clutter of ideas colliding inside his mind. His obsession with Google and his curious mind add to his research-based writing. Other than that, he's a music and art admirer and an overly-excited person.

How to Create Custom Post Type in WordPress (Easy Guide) (2024)
Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6247

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.