How to Create Custom Post Types in WordPress

How to Create Custom Post Types in WordPress

Custom post types can be extremely useful regardless of what type of website you are creating. Custom post types are a key reason WordPress can operate as much more than a simple blogging platform. Following the initial setup, WordPress relies on pages and posts to support the main content. Fortunately, you can create as many different types of content types as you want by leveraging the flexibility and functionality of custom post types.

How to Create Custom Post Types in WordPress

The Easy Way – A Plugin

The easiest way to create custom post types is by using a WordPress plug-in designed to create custom post types. One of the more popular plug-ins is the Custom Post Type UI plugin. This plug-in provides an easy-to-use interface which allows for you to create and manage both custom post types and taxonomies. While there are multiple plug-ins which feature this type of functionality is important to get one you are comfortable using and has a proven track record of remaining updated to ensure it does not conflict with future versions of WordPress.

Manually Creating Custom Post Types

The second option is to create a custom post type manually. People who are comfortable coding in WordPress often choose to create custom post types themselves. This is because if they use the plug-in and it becomes deactivated or is no longer supported then all of the custom post types will disappear. While they will still exist they will become unregistered which means they will not be accessible from the admin area.

Custom post types are typically added to the theme’s functions.php file. Custom post type code will begin by registering the type followed by an array of arguments. All of the arguments are the options within the custom post type. WordPress includes built-in support for displaying custom post types so once you have added them it will be displayed on your website.

There are two common options used to alter the display of custom post type archives/lists. The first is going to the “Menus” option under the Appearance tab and adding a custom link to the menu. This link will be a link to your custom post type. The second option is using a template dedicated to your custom post type archive. To do this you will need to create a new file in the theme directory and insert the code into your template as needed. You will also likely need to create a custom template for your post type’s single entry display. This is often done with a PHP file in your theme directory.

How Should You Add Custom Post Types to Your WordPress Site?

Both a plug-in and manually creating custom post types is a viable option for your website. If you are comfortable coding on your own then there are some benefits to creating custom post types manually however they will require a significant amount of additional work. On the flipside, all of this work will only need to be done once. By using a custom post type plug-in there is no guarantee you will not need to re-create these custom post types when you switch plug-ins or if the plug-in is no longer compatible or supported with future WordPress updates.

1 Comment
  • Rachel G. Collins says:

    Messing with custom post types isn’t something I have really needed to do. I guess that some of the plug-ins I use automatically create custom post types so in a way I use them. I don’t know that I’m comfortable enough designing a layout that creating a custom post type would be helpful. At the same time, I recently switched to a WordPress theme that allows you to design the layout on the front end which might make using a custom post type more helpful.

    If I decide to give it a try, I will definitely use a plug-in like you recommend. I think creating a custom post type is still a little outside my skill set. Plus, one of the reasons I like word press is there seems to be a plug-in for everything. I never thought about it before but I also like the quick tip you gave that by creating a custom post type I will only have to do the work once rather than every time I want a different layout. That is a good point and may make me decide to reconsider my stance on creating custom post types.

Leave a comment

Your email address will not be published.

Post Comment