How to Create Custom Post Types in WordPress the Easy Way

WordPress sites can require different post types. Some will run smoothly using the default post types, while others need custom post types to better serve their content needs. If your website is the latter, this guide shows how to add a WordPress custom post type.

Tip: when setting up your website with WordPress, check out these WordPress hosting services.

How to Create a Custom Post Type in WordPress

You can easily generate a code snippet to create the custom post type you need using GenerateWP’s Post Type Generator. Paste it using a code snippet plugin, such as WPCode, a site-specific plugin, or directly to your theme’s template.

  1. Go to the GenerateWP Post Type Generator page, then click “General.”
Generatewp Post Type Generator Information
  1. Fill out the following fields in the “General” tab:
    • Function Name: the name of your custom post type.
    • Child Theme: if you want the code snippet to support child themes.
    • Text Domain: a unique identifier for your custom post type.
Generatewp Post Type Generator General
  1. Click “Update Code.” Remember to do this after making changes to each section.
Generatewp Post Type Generator General Update Code
  1. Every time you click “Update Code,” what you enter in the fields will be applied to the generated code snippet.
Generatewp Post Type Generator General Update Code Snippet
  1. Go to the “Post Type” section with the following fields:
    • Post Type Key: key to be used in the code.
    • Description: descriptive summary of the custom post type.
    • Singular Name: the name of the custom post type.
    • Plural Name: the name of two or more posts of the custom post type.
    • Link to Taxonomies: for grouping related posts in your website.
    • Hierarchical: if you want posts of this custom post type to be ordered.
Generatewp Post Type Generator Post Type
  1. You can customize how menu items inside this custom post type will appear in the WordPress user interface in the “Labels” tab.
Generatewp Post Type Generator Labels
  1. Select supported items, and manage the search result appearance, exporting, and archival in the “Options” tab. Select “Update Code.”
Generatewp Post Type Generator Options
  1. You can customize how the custom post type appears in your WordPress admin dashboard in the “Visibility” tab.
Generatewp Post Type Generator Visibility
  1. Go to “Permalinks,” and select “Custom permalink” under “Permalink Rewrite” to create a custom URL slug for the custom post type. If you want posts of this type to be divided into pages, select “Yes” under “Pagination.” Select “Update Code.”
Generatewp Post Type Generator Permalinks
  1. You can manage the capabilities of users who can access the custom post type in the “Capabilities” tab.
Generatewp Post Type Generator Capabilities
  1. Highlight the generated code snippet and copy.

FYI: learn which is better: WWW or non-WWW URLs.

How to Add Code Snippets to WordPress Using WPCode

Now that you have the code snippet for your custom post type, paste it to WordPress. We’re using WPCode for ease of use.

  1. In your WordPress dashboard, install and activate WPCode.
  2. You will have a new menu item labeled “Code Snippets.”
  3. Hover over “Code Snippets,” then click “+ Add Snippet.”
Wordpress Menu Code Snippets
  1. On the WPCode page, hover over “Add Your Custom Code (New Snippet),” then click “Use snippet.”
Wordpress Menu Code Snippets Wpcode
  1. Click the toggle beside “Active” to activate the snippet. Add a snippet title, select “PHP Snippet” under “Code Type,” then paste the custom post type code snippet from “GenerateWP” under “Code Preview.” Click “Save Snippet.”
Wordpress Wpcode Create Custom Snippet
  1. The custom post type should appear in your WordPress dashboard’s left sidebar.
Wordpress Menu Custom Post Type

Good to know: if WordPress is too complicated for you, check out these WordPress alternatives for content creation.

How to Display Custom Post Types in WordPress

If you visit your website, you may not see the menu button for the custom post type you just created. Follow the steps below to display custom post types:

  1. Hover over “Appearance” in your WordPress dashboard, then click “Menus.”
Wordpress Appearance Menus
  1. You can create a new main menu or add the custom post type under an existing menu.
  2. Under “Add menu items,” click “Custom Links.” Add the URL slug of the custom post type you created, add the Link Text, then click “Add to Menu.”
Wordpress Appearance Menus Add
  1. Select a location for the menu button under “Menu Settings.”
Wordpress Appearance Menus Add Location
  1. Click “Save Menu” at the bottom right of the “Menus” page.
  2. A new menu button for the custom post type you added will be added at the menu location you selected.

Good to know: learn how to add a custom post status in WordPress.

Frequently Asked Questions

How can I view the available post types in my WordPress theme?

Easily find custom post types using the Find My Custom Post Types plugin. For viewing all registered post types, including default post types, use the get_post_types() function. You can find the code you need in the WordPress Developer Resources page for the get_post_types() function.

How many custom post types are there in WordPress?

You can create as many custom post types as you need, so there is no definitive number.

Is there a WordPress plugin I can use to generate custom post types?

Image credit: Pexels. All screenshots by Natalie dela Vega.

Natalie dela Vega
Natalie dela Vega

Natalie is a writer specializing in tech how-tos and gaming. When she’s not writing, she plays PC games and travels. Here at MakeTechEasier, you will see her write about guides, tips, and solutions for Windows and iOS.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Leave a Reply

Your email address will not be published. Required fields are marked *