Although not necessary for every webmaster, going beyond default post types (posts, pages, attachments, revisions, navigation menus) can improve SEO, help with content visuals and organization, and speed up the workflow. Some great examples include custom Portfolio, Deals, Glossary, Product, Review, or Testimonial post types, which you can even pair with custom taxonomies. Some eCommerce plugins and contact form plugins already offer this but the type is specific and hard to edit. Instead, you can gain complete freedom by learning how to create a custom post type in WordPress. Let’s begin.
1. Create custom post type via WordPress plugin
We’re starting with the easiest, safest, and most convenient method – installing a WordPress plugin with this functionality. We’re not affiliated with the developers, but we’ll use a popular choice to demonstrate the process. Follow these steps to create a custom post type using a WordPress plugin:
- Install and activate Custom Post Type UI (https://wordpress.org/plugins/custom-post-type-ui).
- Note. The name of our custom post type will be Product. Exchange it with yours throughout the guide.
- In the left sidebar in your Admin Section, click on CPT UI > Add/Edit Post Types.
- Under Add New Post Type > Basic settings, start filling out the following information:
- For Post Type Slug, type a WordPress slug for your CPT. Ours is product.
- Under Plural Label, enter Products.
- Under Singular Label, enter Product.
- If you get the option to Auto-populate labels, click on Populate additional labels based on chosen labels. Otherwise, fill out the Additional labels section manually using the provided tips.
- After scrolling down, you’ll see the Settings section. Set True or False based on your needs. In our particular case, we set:
- Public, Publicly Queryable, Show UI, and Show in Nav Menus to True.
- Delete with user to False.
- Finally, it’s time to select which post features will be available when creating/editing custom post types (CPT). For example, you can put a checkmark in front of:
- Title
- Editor
- Excerpt
- Featured Image
- Custom Fields
- Revisions
- Comments
- Click on the Add Post Type button, and you created a custom post type in WordPress successfully.
- Don’t forget to make it visible on the front end after adding content, if that’s your goal.
2. Create custom post type in WordPress manually
This method requires you to add a code snippet for registering custom post types in WordPress. Then, follow the sub-method 2 below to make the custom post type (CPT) appear on the front page next to regular post types. You can also add custom post types to your website RSS feed afterward.
Display custom post types on the front end
Depending on the method you used, after you filled it up with appropriate content, it’s time to display CPT on the front-end. Follow these steps to show your custom post types on your website:
1. Make CPT appear in menus
This is only necessary if you followed method 1. It will add a custom link to your left sidebar menu in WordPress Admin Section. Here’s what to do:
- Click on Appearance > Menus.
- Add a new Custom Link menu item.
- Under URL, enter your website URL followed by the slug you chose. For us, it’s https://wpthinker.com/products.
- Under Link Text, give it a name such as Products.
- Click on Add to Menu.
2. Display CPT on the front page
You can add this piece of code in the same places as method 2. It will make your custom post types appear alongside regular post types on your website front end. Add this code and replace the bolded part:
add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
function add_my_post_types_to_query( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'products' ) );
return $query;
}