Beginner's Guide for WordPress / Start your WordPress Blog in minutes

What is: Custom Post Type

In WordPress, custom post types are used when you want to create content that’s different from a normal post or page.

For example, you can create custom post types for portfolios, testimonials, and products. Many WordPress plugins also use custom post types to store data.

If you decide to use custom post types on your website, then you will need to learn how to create them and display them on your WordPress site. You will also need to add them to your search results and decide how to organize them.

What Is a Custom Post Type in WordPress?

What Is a Custom Post Type?

Post types are used to help distinguish between different types of content in WordPress. For example, posts and pages are both post types but are made to serve different purposes.

WordPress comes with a few default post types:

  • Post
  • Page
  • Attachment
  • Revision
  • Nav Menu

You can also create your own new post types, and these are known as custom post types.

Custom post types can have different custom fields and their own custom category structure. They are useful when creating custom content with a different format to standard posts and pages.

For example, you could create custom post types for portfolios, testimonials, and products. A movie review website could have a ‘movie reviews’ post type.

On WPBeginner, we use custom post types to keep our Deals and Glossary sections separate from our daily blog articles. It helps us better organize our website content.

The WPBeginner Website Uses Custom Post Types for Deals and Glossary

Many popular WordPress plugins use custom post types to store data on your WordPress website. The following are a few top plugins that use custom post types:

  • WooCommerce adds a ‘product’ post type to your online store.
  • WPForms creates a ‘wpforms’ post type to store all your forms.
  • MemberPress adds a ‘memberpressproduct’ custom post type.

When Should You Use Custom Post Types?

You can often use built-in WordPress features such as categories and tags to organize your content without needing to use custom post types. For example, you can set up a hierarchical layout of content using child pages and also set up subcategories.

Using these default WordPress features is often easier since, by default, custom post types won’t appear on your blog page, in search results, or in your RSS feeds.

After looking at the default options, you may find that you don’t need custom post types after all. If you are unsure, then refer to this guide about when you need a custom post type or taxonomy in WordPress.

How to Create a Custom Post Type in WordPress

If you decide to use custom post types on your blog, then the easiest way to create them is with a plugin. The Custom Post Type UI plugin is recommended for most users and lets you create custom post types from the ‘Edit/Add Post Types’ page.

Create a New Custom Post Type With a Plugin

Alternatively, you can add a new custom post type by pasting a code snippet into your theme’s functions.php file or using a snippet plugin like WPCode. The advantage of this method is that your custom post types won’t disappear if the plugin is deactivated.

You can learn more in our guide on how to create custom post types in WordPress.

How to Display Custom Post Types in WordPress

You can also use Custom Post Type UI to display your custom post types on your website.

Displaying Custom Post Type Archive Pages

Before you can view the archive page for your custom post type, you must make sure that archives are enabled for your custom post type.

If they are not, then you can enable them in Custom Post Type UI’s advanced options.

CPT UI turn on archive

If you have SEO-friendly permalinks enabled, then you can visit your custom post type archive at a URL like this one:

http://www.example.com/movies/

You will have to replace ‘example.com’ with your own domain name and ‘movies’ with your custom post type name.

Displaying Custom Post Types on Your Navigation Menu

Now that you know the URL of the archive page, you can add it to your navigation menu. You can also customize the archive page by adding a custom template to your WordPress theme or using a theme builder like SeedProd.

Edit your post type page

We show you how to do all of these things step by step in our guide on how to create a custom post types archive page in WordPress.

Displaying Sticky Custom Posts

Finally, if you would like to pin your most important custom posts to the top of the page, then you can follow our guide on how to add sticky posts in WordPress custom post type archives.

How to Search Custom Post Types in WordPress

By default, WordPress won’t show custom post types in its on-site search results. That means your visitors may miss out on some great content, and you’ll miss out on extra page views.

Including Custom Post Types in Search Results

The easiest way to include custom post types in WordPress search is with the SearchWP plugin. Simply click on the plugin’s ‘Sources & Settings’ button. Here, you can put a checkmark next to each post type you wish to include in search results.

Including custom post types in WordPress search

You can also choose how important each custom post type is when displaying search results and customize the search engine in other ways.

To learn how, just see our step-by-step guide on how to include custom post types in WordPress search results.

Creating a Search Form for Custom Post Types

You can also use SearchWP to create a custom search form that will only show results from your custom post type, then add the form to your posts or sidebar.

For example, if you have a custom post type called ‘movies’, then you can create a special movie search form that only returns movies in the search results.

For more details, see our guide on how to create an advanced search form in WordPress for custom post types.

How to Organize Custom Post Types in WordPress

By default, you won’t have a way to organize your custom post types. WordPress categories can only be used to organize posts, not custom post types.

Adding Categories to a Custom Post Type

Luckily, you can use Custom Post Type UI to associate categories with custom post types.

Allowing Custom Post Types to Use Categories

Simply check the ‘Categories (WP Core)’ box in the plugin’s ’Taxonomies’ area, and you will be able to use categories to organize your custom post types.

Learn more in our guide on how to add categories to a custom post type in WordPress.

Creating Custom Taxonomies for a Custom Post Type

Alternatively, you can create a new custom taxonomy to organize your custom post type. For instance, if you have a custom post type called ‘Books’, then you can sort it using a custom taxonomy called ‘Topics’.

Then, you can add topic terms like Adventure, Romance, Horror, and other book topics. This will allow your readers to easily sort books by topic.

Get started by following our guide on how to create custom taxonomies in WordPress.

How to Subscribe to Custom Post Types in WordPress

WordPress only includes your blog posts in your site’s main RSS feed. This means your custom post type content won’t be visible to your main RSS feed subscribers.

You can easily include all publicly available post types into your main RSS feed by adding the following custom code to your theme’s functions.php file or a snippet plugin like WPCode:

function myfeed_request($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();
return $qv;
}
add_filter('request', 'myfeed_request');

For more details on both methods, see our guide on how to add custom post types to your main WordPress RSS feed.

Alternatively, you may want to learn how to make a separate RSS feed for each custom post type in WordPress.

We hope this article helped you learn more about custom post types in WordPress. You may also want to see our Additional Reading list below for related articles on useful WordPress tips, tricks, and ideas.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Additional Reading

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!