Custom post types
6 min read
A post type is a kind of content. WordPress ships with Posts and Pages; a custom post type adds your own, such as Books, Events or Team Members. Each type gets its own admin menu, its own list screen and its own URLs.
Mass Custom Fields lets you register post types without writing PHP. The definition is stored in the plugin's settings table and registered with WordPress on every request, exactly as if you had called register_post_type() yourself.
Custom post types are available on every plan.
Where to find it
Open WPM Fields › Post Types in the WordPress admin menu. The page subtitle reads "Register post types with every option WordPress offers, labels included."
The list has these columns:
Column | Meaning |
|---|---|
Key | The post type key, for example |
Plural label | The name shown in the admin menu, for example "Books". |
Status | Active or inactive. |
Archive | "On" when the type has an archive page, a dash when it does not. |
REST API | "On" when the type is exposed in the REST API. |
Click a row to edit it. Use Add post type (top right) to create one. The same command is also available from the Ctrl/⌘ K search.
Create a post type
- Open WPM Fields › Post Types and click Add post type.
- Type a Plural label ("Books") and a Singular label ("Book"). Both are required.
- Check the Post type key. It is filled in from the singular label until you edit it yourself ("Book" becomes
book). - Choose the toggles described below, then click Create post type.
- A "Post type created." message appears and the new type shows up in the admin menu on the next page load.
The Basics section
Field | Default | What it does |
|---|---|---|
Plural label | empty (required) | Menu name and list titles ("All Books"). |
Singular label | empty (required) | Used in "Add New Book", "Edit Book" and similar labels. |
Post type key | from the singular label | Lowercase letters, numbers, hyphens and underscores, 1 to 20 characters. Cannot be changed after creation, because posts are stored under this key. |
Public | On | "Show it in the admin and on the site (when the visibility settings allow)." Turn off for content that should never have its own page. |
Hierarchical | Off | "Like pages: entries can have a parent." Also changes the default wording of the featured image labels to "Cover Image". |
Active | On | When off, the post type is not registered. Its content stays in the database. |
Advanced settings | Off | Reveals six tabs with every other option. |
With Advanced settings off, everything on the tabs keeps its default (see the tab pages below). You can leave them off for a simple type.
Key rules
The key is checked when you save. You will see one of these messages:
- "Post type key is required."
- "Post type key must be 1–20 characters: lowercase letters, numbers, hyphens, underscores only."
- "A post type with this key already exists in Mass Custom Fields."
- "This post type key is reserved by WordPress." This covers core types (
post,page,attachment,revision,nav_menu_item,wp_block,wp_templateand others) and WordPress's reserved query words (type,name,year,page,author,search,order,title,statusand more). A reserved key would break WordPress queries. - "This post type is already registered by WordPress or another plugin."
Choose a short, specific key (wpm_book rather than book) if another plugin or theme might register the same one.
The editor tabs
When Advanced settings is on, six tabs appear below the Basics section:
Tab | Page |
|---|---|
General, Labels | |
Visibility, URLs | |
Permissions, REST API |
Tabs only appear while Advanced settings is on. Their values are kept when you switch it off again, and still apply.
Edit a post type
Click the row in the list. The page title becomes the plural label. Everything except the key can be changed. Click Save changes; you see "Post type saved." If you leave with unsaved changes, a confirmation dialog asks first.
Changes to labels, menu and supports take effect on the next page load. Changes that affect URLs (the permalink slug, archive, feeds, pagination, front prefix, taxonomy slugs) also schedule a rewrite flush, described next.
Permalinks: do you need to "Save Permalinks"?
No. Whenever you create, edit or delete a post type (or a taxonomy), the plugin sets a flag. On the next page load (any admin or front-end request) WordPress registers all types first and then rebuilds the rewrite rules once. You do not need to visit Settings › Permalinks.
If a URL still returns a 404 after one more page load:
- The permalink structure under Settings › Permalinks must not be "Plain". Plain permalinks do not support pretty URLs for any post type.
- Another plugin may be registering the same slug. Pick a different Custom slug.
- Open Settings › Permalinks and click Save Changes once. This is safe and forces a full rebuild.
Active, inactive and deleted
State | Registered | Posts in the database | In the admin |
|---|---|---|---|
Active | Yes | Yes | Menu, list screen, editor |
Inactive (Active toggle off) | No | Kept | Hidden. Posts cannot be opened. |
Deleted (trash icon in the list) | No | Kept | Hidden. |
Deleting asks "Delete post type?" and explains: "This removes the registration for «key». Existing posts are not deleted." Only the definition is removed. The posts stay in the posts table with their old type and become reachable again if you create a type with the same key later.
Things that stop working while a type is not registered:
- Its menu entry, list screen and front-end URLs.
- Taxonomies cannot be attached to it. Saving a taxonomy that lists an inactive or missing type fails with
Post type "key" does not exist. - Field groups located on it still exist, but the location rule has nothing to match.
If another plugin or theme already registered a type with the same key when your definition loads, the plugin silently skips its own registration and the other one wins.
Show it on your site
An active, public type with Archive page on is available at /{slug}/ (see Visibility and URLs). Single entries live at /{slug}/{post-name}/. Query them in a template like any post type:
$books = new WP_Query( array(
'post_type' => 'book',
'posts_per_page' => 10,
) );Attach field groups to the type with the Post type location rule, see Location rules. Read values with the template functions.
Hooks for developers
Hook | Type | Purpose |
|---|---|---|
| action | Fires before registration. Arguments: |
| filter | Change the final |
| action | Fires after registration. |
| action | A definition was saved or deleted. Argument: the key. |
| filter | Allow-list of PHP function names a definition may use as Meta box callback. Empty by default. |
add_filter( 'wpmcf/post_types/register_args', function ( array $args, string $name ) {
if ( 'book' === $name ) {
$args['show_in_graphql'] = true;
}
return $args;
}, 10, 2 );See also Hooks and variables.
Troubleshooting
The menu entry does not appear. Check that Active is on, Show in admin (Visibility tab) is on, and Admin menu is not "Hide from the admin menu". Reload the page once.
"This post type is already registered by WordPress or another plugin." Another plugin owns the key. Use another key, or deactivate that plugin. (Imports and migrations from other plugins save such a type as inactive, so you can switch over later.)
I cannot rename the key. Not supported; the field is read-only after creation. Create a new type with the new key, move the posts (for example with a bulk edit plugin), then delete the old definition.
Posts disappeared after I deleted the type. They are still in the database. Create a type with the same key again to bring them back.
A 404 on single entries or the archive. See "Permalinks" above.
Still stuck? Contact support