This documentation describes unreleased changes on the main branch.

#[PostType]

Attribute on classes.

use Saij\WpAppFramework\Post\PostType;

Declares a post type on a subclass of AbstractPost: the class is the object of a post of the type. The framework registers the type as {namespace}_{name} (namespace of the theme or plugin with "_" instead of "-"), always shown in the REST API and therefore in the block editor if it supports the editor.

Arguments

#[PostType(string $name, string $label, string $singularLabel, ?PostTypeLabels $labels = null, string $description = '', bool $public = true, bool $showUi = true, array $supports = [PostTypeSupport::Title, PostTypeSupport::Editor], bool $hierarchical = false, bool $archive = false, ?string $slug = null, ?string $menuIcon = null, ?int $menuPosition = null)]
ParameterTypeDefaultDescription
namestringrequiredName without namespace: lowercase letters, digits and "_", starting with a letter; the full name has at most 20 characters.
labelstringrequiredPlural name, e.g. "Events".
singularLabelstringrequiredSingular name, e.g. "Event".
labelsPostTypeLabels|nullnullFurther labels; null derives all of them from the names in English.
descriptionstring''Description of the post type.
publicbooltrueThe type is shown on the front end and in searches; false for data without pages of its own. Unlike in WordPress, true by default.
showUibooltrueThe type has screens and a menu entry in the admin.
supportslist<PostTypeSupport>[PostTypeSupport::Title, PostTypeSupport::Editor]Features of the type; custom-fields is added for meta.
hierarchicalboolfalsePosts have parents, like pages.
archiveboolfalseThe type has an archive page at its slug.
slugstring|nullnullURL slug; null uses the name with "-" instead of "_".
menuIconstring|nullnullDashicon class or URL of the admin menu icon.
menuPositionint|nullnullPosition in the admin menu (WordPress' menu_position); null puts it below Comments.