wppaste
WordPress

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.

Properties · 40

$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).
$publicly_queryableboolpublic
Whether queries can be performed on the front end for the post type as part of parse_request().
$show_uiboolpublic
Whether to generate and allow a UI for managing this post type in the admin.
$show_in_menubool|stringpublic
Where to show the post type in the admin menu.
$show_in_nav_menusboolpublic
Makes this post type available for selection in navigation menus.
$show_in_admin_barboolpublic
Makes this post type available via the admin bar.
$menu_positionintpublic
The position in the menu order the post type should appear.
$menu_iconstringpublic
The URL or reference to the icon to be used for this menu.
$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.
$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

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_search

Changelog

Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.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.