How to Create Custom Post Types in WordPress
Learn how to create custom post types in WordPress with code or plugins, add custom fields, set clean URLs, and show content on the front end.
Introduction to Custom Post Types
If you need to know how to create custom post types in WordPress, start with the content model. A post type gives one kind of content its own editing area, fields, URLs, and templates.
WordPress ships with five default post types. They are post, page, attachment, revision, and menu. The menu type is often named nav_menu_item in WordPress code.
Custom post types suit content that needs a set layout. Events, products, properties, courses, and testimonials are common examples. Each item can have details beyond a title and main editor.
Plan the content before you write code. List its fields, taxonomies, URL path, archive needs, and display rules. This step keeps the build clean.
- Choose one clear purpose for the type
- List the data editors must enter
- Pick a short, unique slug
- Decide if the type needs an archive page
Benefits of Using Custom Post Types
WordPress custom post types keep related content in one place. Editors see a focused screen instead of one crowded post form. Visitors get clearer paths and menus.
An event may need a date, venue, ticket link, and speaker list. A testimonial may need a client name, role, quote, and rating. Separate fields make both types easier to manage.
Each type can use its own slug and URL structure. An event type may use /events/. A product type may use /products/.
Clear URLs help users scan a site. They also give search engines useful page context. Good structure cannot replace useful page content.
Custom taxonomies add another layer of order. You could group events by city or testimonials by service. Use a taxonomy when editors need to filter or group many items.
Creating Custom Post Types with Code
WordPress post type registration uses register_post_type(). Run this function on the init hook. A custom plugin is the safest home for the code.
The example below creates an event type. Add it to a site plugin, then change the labels and slug for your project.
Example: add_action( 'init', 'tw_register_event' ); function tw_register_event() { register_post_type( 'tw_event', array( 'labels' => array( 'name' => 'Events', 'singular_name' => 'Event' ), 'public' => true, 'has_archive' => true, 'rewrite' => array( 'slug' => 'events' ), 'supports' => array( 'title', 'editor', 'thumbnail' ), 'show_in_rest' => true ) ); }
The identifier is tw_event. The short prefix lowers the risk of name clashes. The public setting makes the type available on the site.
The archive setting creates an event list page. The supports list controls editor tools. Add excerpt, author, comments, or revisions only when needed.
Review the WordPress register_post_type reference for less common settings. It explains each argument and its accepted values.
After changing rewrite settings, visit Settings, then Permalinks. Save that page once. This refreshes the site's rewrite rules.
Choose Safe Names and Labels
Use a lowercase identifier with no spaces. Keep it short and add a project prefix. Avoid vague names such as item, content, or data.
Use labels that editors understand at a glance. “Events” is better than “TW Entries” in the admin area. Good labels reduce training time.

Using Plugins to Create Custom Post Types
A plugin can create a post type without manual PHP work. This option suits site owners who do not edit code. It also helps teams that need a quick setup.
CPT UI is a known option for this task. It lets you set labels, slugs, archives, and editor support. You still need a plan for fields and templates.
Plugin settings can move with the site while the plugin stays active. Export the setup when the tool supports it. Keep a backup before changing a live site.
Do not add a new plugin for every small field. Several field tools can create duplicate data. Pick one system and record who owns each setting.
- Choose a clear type name and slug
- Set the public and archive options
- Add only the editor features you need
- Create one test item and review its URL
- Build the archive and single templates
Adding Custom Fields to Custom Post Types
Custom fields in WordPress store details beyond the title and main editor. An event could have a start date, venue, price, and booking link. A property could have a price, area, and room count.
If you are learning how to create custom fields in WordPress, first define the field type. Text suits a short label. A date field suits an event date. A link field suits a booking page.
Many site owners also ask how to use custom fields in WordPress. Add fields only when a value has a clear job. The theme or block template must show that value later.
Custom taxonomies work well for repeatable groups. Use a field for one value, such as a venue. Use a taxonomy for shared terms, such as cities or event types.
| Need | Best fit |
|---|---|
| One date or price | Custom field |
| Shared groups | Custom taxonomy |
| Long page copy | Main editor |
| Reusable layout | Block or template |
Block themes and the Gutenberg editor can show field data through templates or blocks. You do not need a custom Gutenberg block for every value. Start with the simplest display method.

Displaying Custom Post Types on the Front End
Registration only creates the content type. You must still build its archive and single views. A theme can supply these views with files such as an archive template and a single template.
The archive lists many items. The single view shows one item in full. Keep both views focused on the fields that matter to readers.
To learn how to display custom field value in WordPress, fetch the saved value inside the right template. A basic example uses get_post_meta() with the current post ID and field key.
To learn how to display custom fields in WordPress, place each value near its related content. Show a date near the event title. Show a venue near the map or address.
Check that empty fields do not leave blank labels. Add a condition before each optional value. This keeps the page tidy when editors skip a field.
Test the Archive and Single View
Create two or three test entries with different field values. Check the archive, single page, menus, images, and mobile layout. Test an entry with missing optional data.
Also check the site after a theme change. A post type registered in a theme may vanish from the editor when that theme is replaced. Plugin registration avoids that problem.
Best Practices for WordPress Custom Post Types
Register stable content types in plugins, not themes. A theme controls presentation. A plugin should own content that must survive a design change.
Use meaningful identifiers and a unique prefix. Keep the slug stable after launch. Changing it can break links and create needless redirects.
Keep field names consistent across templates. Write a short note that lists each field key, type, and purpose. This note helps future developers avoid guesswork.
Give editors only the tools they need. Fewer choices make mistakes less likely. Clean admin screens also speed up publishing.
- Back up before changing post type settings
- Use a prefix for custom identifiers
- Keep registration code in a site plugin
- Refresh permalinks after rewrite changes
- Test empty and complete field sets
- Review archive and single page links
Do not create a custom post type for a one-off page. A normal page may be enough. Use a new type when the content repeats and needs its own structure.
Frequently asked questions
- How do I create custom post types in WordPress?
- Use register_post_type() on the init hook. Put the code in a custom plugin, then set labels, slug, archive, and editor support.
- Should I register a custom post type in a plugin or theme?
- Use a plugin for content that must remain after a theme change. Themes should mainly control layout and style.
- What are custom fields in WordPress used for?
- Custom fields store structured details such as dates, prices, venues, and product codes. Templates can show each value in the right place.
- How do I display a custom field value in WordPress?
- Use the field tool's output method or get_post_meta() inside the right template. Check that the value exists before showing its label.
- What is the difference between a custom field and a taxonomy?
- A custom field stores a value for one item. A taxonomy groups many items under shared terms, such as cities or event types.
- Do custom post types help WordPress SEO?
- They can create clear URLs and useful page groups. They do not replace strong content, sound links, or good page speed.
Related reading
Does WordPress Host Websites? A Clear Guide to Your Options
Learn how WordPress hosting works and choose the right setup for your site.
How to Align Web Development and Digital Marketing Before Launch
A practical guide to aligning web development and digital marketing before launch — goals, keywords, tracking, performance, and the checklists that keep both teams honest.
Where WordPress Stores Images, Pages, and Media Data
Find WordPress images, database records, folders, and image sizes.