WP_Post_Type::__construct() WordPress Method

The WP_Post_Type::__construct() function sets up a new post type object. It takes two arguments: the post type slug and an array of options. The options array can contain the following keys: - labels: an array of labels for the post type, including the name, singular_name, menu_name, and description keys. - description: a short description of the post type. - public: whether the post type is public. - hierarchical: whether the post type is hierarchical. - show_ui: whether to show the post type in the admin interface. - show_in_menu: whether to show the post type in the admin menu. - show_in_nav_menus: whether to show the post type in the admin navigation menus. - show_in_rest: whether to show the post type in the WordPress REST API. -rest_base: the base path for the post type in the WordPress REST API. -menu_position: the position in the admin menu for the post type. -menu_icon: the icon for the post type in the admin menu. -capability_type: the capability type for the post type. -map_meta_cap: whether to map the post type's capabilities. -supports: an array of features the post type supports. - register_meta_box_cb: a callback function for registering meta boxes for the post type. - taxonomies: an array of taxonomies the post type supports. - has_archive: whether the post type has an archive. - permalink_epmask: the permalink structure for the post type. - query_var: the name of the query var for the post type. - can_export: whether the post type can be exported. - delete_with_user: whether to delete the post type when the user is deleted.

WP_Post_Type::__construct( string $post_type, array|string $args = array() ) #

Constructor.


Description

See the register_post_type() function for accepted arguments for $args.

Will populate object properties from the provided arguments and assign other default properties based on that information.

Top ↑

See also


Top ↑

Parameters

$post_type

(string)(Required)Post type key.

$args

(array|string)(Optional) Array or string of arguments for registering a post type.

Default value: array()


Top ↑

Source

File: wp-includes/class-wp-post-type.php

	public function __construct( $post_type, $args = array() ) {
		$this->name = $post_type;

		$this->set_props( $args );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.