posttypes.json
This file, as you might expect, is responsible for registering custom post types.
Defaults
PorterWP has a set of defaults for post type creation, which makes the processing of registering new post types very clean. The default settings are:
You can filter these default values by using the filter porter_default_object_args
where the $group
is "posttype"
See for more information.
Register new post type
Registering a new post type is as easy as adding a new item to the post types object.
For example, adding an event would look like this:
ALWAYS use singular names for posttype registration. Not just in PorterWP, but always.
e.g. event
not events
PorterWP will attempt to generate servicable labels, but you can override them if you'd prefer to define your own labels.
For example the plural of Research is Research, not Researchs (which is what PorterWP would generate by default). So if you were registering a posttype called "research" you would do the following:
You can of course set any other params from from register_post_type
function here, too. (ref: https://developer.wordpress.org/reference/functions/register_post_type/)
For example:
If you need to adjust the "supports" options from the default settings, you must include ALL supported elements. PorterWP will assume you don't want to use the default "supports" settings.
Last updated