-
Notifications
You must be signed in to change notification settings - Fork 5
post type
Alberto Parziale edited this page Aug 30, 2019
·
2 revisions
Aeria makes declaring new post types a breeze. No need to edit your functions.php
file! Just add a configuration file to /themes/[Your active theme]/aeria-config
. Like the other ones, post type configuration files require three main fields:
-
"name"
defines the name for this post type. It will be used as post type key. -
"kind"
defines the type of configuration: we're gonna set it to "post-type" this time. -
"spec"
defines the specific configurations for the object.
The available specs are the ones available in Wordpress' register_post_type()
function, you can check its reference here.
Let's analyze this example configuration.
{
"name": "book",
"spec": {
"menu_icon": "dashicons-book",
"labels": {
"name": "Books",
"all_items": "All Books",
"menu_name": "Books",
"singular_name": "Book",
"edit_item": "Edit Book",
"new_item": "New Book",
"view_item": "View Book",
"items_archive": "Book Archive",
"search_items": "Search Books",
"not_found": "No books found.",
"not_found_in_trash": "No books found in trash."
},
"public": true,
"show_ui": true,
"show_in_menu": true,
"menu_position": 1
},
"kind": "post-type"
}
-
"name"
sets the post type's key."name"
may only contain lowercase alphanumeric chars, dashes, and underscores. -
"menu_icon"
sets the post type's icon in the dashboard's menu. -
"labels"
is an array containing the messages shown to the user in the dashboard. For a full list, check the reference forget_post_type_labels()
. -
"public"
is a boolean stating if the post type is intended for use publicly, either via the admin interface or by front-end users. -
"show_ui"
is a boolean allowing to generate a post type managing UI in the admin menu. -
"show_in_menu"
is a boolean stating if the post type will be available in the admin menu. For it to work,"show_ui"
must be true. -
"menu_position"
is the position where the post type manager will appear in the UI.
You can now proceed to add some metaboxes to this post type.