WP_Post_Type
- Since
- 4.6.0
- Source
wp-includes/class-wp-post-type.php:17
Core class used for interacting with post types.
Compatibility
- WordPress
- since 4.6.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 2
Every hook that fires from inside WP_Post_Type, in the order it appears in the class, grouped by the method that fires it.
WP_Post_Type::set_props()
- apply_filters( register_post_type_args )filter line 501
- apply_filters( register_{$post_type}_post_type_args )filter line 522
Properties · 41
$namestringpublic- Post type key.
$labelstringpublic- Name of the post type shown in the menu. Usually plural.
$labelsstdClasspublic- Labels object for this post type.
$default_labels(string|null)[][]protected static- Default labels.
$descriptionstringpublic- A short descriptive summary of what the post type is.
$publicboolpublic- Whether a post type is intended for use publicly either via the admin interface or by front-end users.
$hierarchicalboolpublic- Whether the post type is hierarchical (e.g. page).
$exclude_from_searchboolpublic- Whether to exclude posts with this post type from front end search results.
$publicly_queryableboolpublic- Whether queries can be performed on the front end for the post type as part of
parse_request(). $embeddableboolpublic- Whether this post type is embeddable.
$show_uiboolpublic- Whether to generate and allow a UI for managing this post type in the admin.
$show_in_admin_barboolpublic- Makes this post type available via the admin bar.
$capability_typestringpublic- The string to use to build the read, edit, and delete capabilities.
$map_meta_capboolpublic- Whether to use the internal default meta capability handling.
$register_meta_box_cbcallablepublic- Provide a callback function that sets up the meta boxes for the edit form.
$taxonomiesstring[]public- An array of taxonomy identifiers that will be registered for the post type.
$has_archivebool|stringpublic- Whether there should be post type archives, or if a string, the archive slug to use.
$query_varstring|boolpublic- Sets the query_var key for this post type.
$can_exportboolpublic- Whether to allow this post type to be exported.
$delete_with_userboolpublic- Whether to delete posts of this type when deleting a user.
$templatearray[]public- Array of blocks to use as the default initial state for an editor session.
$template_lockstring|falsepublic- Whether the block template should be locked if $template is set.
$_builtinboolpublic- Whether this post type is a native or "built-in" post_type.
$_edit_linkstringpublic- URL segment to use for edit link of this post type.
$capstdClasspublic- Post type capabilities.
$rewritearray|falsepublic- Triggers the handling of rewrites for this post type.
$supportsarray|boolpublic- The features supported by the post type.
$show_in_restboolpublic- Whether this post type should appear in the REST API.
$rest_basestring|boolpublic- The base path for this post type's REST API endpoints.
$rest_namespacestring|boolpublic- The namespace for this post type's REST API endpoints.
$rest_controller_classstring|boolpublic- The controller for this post type's REST API endpoints.
$rest_controllerWP_REST_Controllerpublic- The controller instance for this post type's REST API endpoints.
$revisions_rest_controller_classstring|boolpublic- The controller for this post type's revisions REST API endpoints.
$revisions_rest_controllerWP_REST_Controllerpublic- The controller instance for this post type's revisions REST API endpoints.
$autosave_rest_controller_classstring|boolpublic- The controller for this post type's autosave REST API endpoints.
$autosave_rest_controllerWP_REST_Controllerpublic- The controller instance for this post type's autosave REST API endpoints.
$late_route_registrationboolpublic- A flag to register the post type REST API controller after its associated autosave / revisions controllers, instead of before. Registration order affects route matching priority.
Methods · 17
- __construct()Constructor.
- set_props()Sets post type properties.
- add_supports()Sets the features support for the post type.
- add_rewrite_rules()Adds the necessary rewrite rules for the post type.
- register_meta_boxes()Registers the post type meta box if a custom callback was specified.
- add_hooks()Adds the future post hook action for the post type.
- register_taxonomies()Registers the taxonomies for the post type.
- remove_supports()Removes the features support for the post type.
- remove_rewrite_rules()Removes any rewrite rules, permastructs, and rules for the post type.
- unregister_meta_boxes()Unregisters the post type meta box if a custom callback was specified.
- unregister_taxonomies()Removes the post type from all taxonomies.
- remove_hooks()Removes the future post hook action for the post type.
- get_rest_controller()Gets the REST API controller for this post type.
- get_revisions_rest_controller()Gets the REST API revisions controller for this post type.
- get_autosave_rest_controller()Gets the REST API autosave controller for this post type.
- get_default_labels()Returns the default labels for post types.
- reset_default_labels()Resets the cache for the default labels.
Source code
#[AllowDynamicProperties]final class WP_Post_Type { /** * Post type key. * * @since 4.6.0 * @var string $name */ public $name; /** * Name of the post type shown in the menu. Usually plural. * * @since 4.6.0 * @var string $label */ public $label; /** * Labels object for this post type. * * If not set, post labels are inherited for non-hierarchical types * and page labels for hierarchical ones. * * @see get_post_type_labels() * * @since 4.6.0 * @var stdClass $labels */ public $labels; /** * Default labels. * * @since 6.0.0 * @var (string|null)[][] $default_labels */ protected static $default_labels = array(); /** * A short descriptive summary of what the post type is. * * Default empty. * * @since 4.6.0 * @var string $description */ public $description = ''; /** * Whether a post type is intended for use publicly either via the admin interface or by front-end users. * * While the default settings of $exclude_from_search, $publicly_queryable, $show_ui, and $show_in_nav_menus * are inherited from public, each does not rely on this relationship and controls a very specific intention. * * Default false. * * @since 4.6.0 * @var bool $public */ public $public = false; /** * Whether the post type is hierarchical (e.g. page). * * Default false. * * @since 4.6.0 * @var bool $hierarchical */ public $hierarchical = false; /** * Whether to exclude posts with this post type from front end search * results. * * Default is the opposite value of $public. * * @since 4.6.0 * @var bool $exclude_from_searchChangelog
Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-post-type.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.