get_post_type_object( string $post_type )
Retrieves a post type object by name.
Contents
Description #Description
See also #See also
Parameters #Parameters
- $post_type
-
(string) (Required) The name of a registered post type.
Return #Return
(WP_Post_Type|null) WP_Post_Type object if it exists, null otherwise.
Source #Source
File: wp-includes/post.php
function get_post_type_object( $post_type ) { global $wp_post_types; if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) { return null; } return $wp_post_types[ $post_type ]; }
Expand full source code Collapse full source code View on Trac
Changelog #Changelog
Version | Description |
---|---|
4.6.0 | Object returned is now an instance of WP_Post_Type . |
3.0.0 | Introduced. |
Related #Related
Used By #Used By
Used By | Description |
---|---|
wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php: WP_REST_Blocks_Controller::check_read_permission() |
Checks if a block can be read. |
wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php: WP_REST_Autosaves_Controller::__construct() |
Constructor. |
wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php: WP_REST_Autosaves_Controller::get_items_permissions_check() |
Checks if a given request has access to get autosaves. |
wp-includes/rest-api/search/class-wp-rest-post-search-handler.php: WP_REST_Post_Search_Handler::detect_rest_item_route() |
Attempts to detect the route to access a single item. |
wp-admin/includes/post.php: use_block_editor_for_post_type() |
Return whether a post type is compatible with the block editor. |
wp-admin/includes/meta-boxes.php: register_and_do_post_meta_boxes() |
Registers the default post meta boxes, and runs the |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_available_actions() |
Get the link relations available for the post and current user. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::check_changeset_lock_with_heartbeat() |
Check locked changeset with heartbeat API. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::handle_override_changeset_lock_request() |
Removes changeset lock when take over request is sent via Ajax. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::handle_dismiss_autosave_or_lock_request() |
Delete a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::handle_changeset_trash_request() |
Handle request to trash a changeset. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::grant_edit_post_capability_for_changeset() |
Re-map ‘edit_post’ meta cap for a customize_changeset post to be the same as ‘customize’ maps. |
wp-includes/general-template.php: get_the_post_type_description() |
Retrieves the description for a post type archive. |
wp-admin/press-this.php: wp_load_press_this() | |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::get_item() |
Retrieves one revision from the collection. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::delete_item_permissions_check() |
Checks if a given request has access to delete a revision. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::__construct() |
Constructor. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::get_items_permissions_check() |
Checks if a given request has access to get revisions. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::create_item_permissions_check() |
Checks if a given request has access to create an attachment. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::prepare_links() |
Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::prepare_links() |
Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_item_schema() |
Retrieves the post’s schema, conforming to JSON Schema. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_collection_params() |
Retrieves the query params for the posts collection. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::sanitize_post_statuses() |
Sanitizes and validates the list of post statuses, including whether the user can query private statuses. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::check_is_post_type_allowed() |
Checks if a given post type can be viewed or managed. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::check_read_permission() |
Checks if a post can be read. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::check_update_permission() |
Checks if a post can be edited. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::check_create_permission() |
Checks if a post can be created. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::check_delete_permission() |
Checks if a post can be deleted. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::prepare_item_for_response() |
Prepares a single post output for response. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::prepare_item_for_database() |
Prepares a single post for create or update. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::update_item_permissions_check() |
Checks if a given request has access to update a post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_item() |
Retrieves a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::create_item_permissions_check() |
Checks if a given request has access to create a post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::__construct() |
Constructor. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_items_permissions_check() |
Checks if a given request has access to read posts. |
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php: WP_REST_Post_Types_Controller::get_item() |
Retrieves a specific post type. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::check_read_post_permission() |
Checks if the post can be read. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::prepare_links() |
Prepares links for the request. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::print_post_type_container() |
Print the markup for new menu items. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::sanitize_nav_menus_created_posts() |
Sanitize post IDs for posts created for nav menu items to be published. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::ajax_insert_auto_draft_post() |
Ajax handler for adding a new auto-draft post. |
wp-includes/customize/class-wp-customize-nav-menu-item-setting.php: WP_Customize_Nav_Menu_Item_Setting::get_original_title() |
Get original title. |
wp-includes/customize/class-wp-customize-nav-menu-item-setting.php: WP_Customize_Nav_Menu_Item_Setting::get_type_label() |
Get type label. |
wp-includes/post.php: unregister_post_type() |
Unregisters a post type. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_pane_settings() |
Print JavaScript settings for parent window. |
wp-includes/link-template.php: get_preview_post_link() |
Retrieves the URL used for the post preview. |
wp-includes/post.php: is_post_type_viewable() |
Determines whether a post type is considered “viewable”. |
wp-includes/admin-bar.php: wp_admin_bar_customize_menu() |
Adds the “Customize” link to the Toolbar. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::_toggle_sticky() |
Encapsulate the logic for sticking a post and determining if the user has permission to do so |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::enqueue_scripts() |
Enqueue scripts and styles for Customizer pane. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::load_available_items_query() |
Performs the post_type and taxonomy queries for loading available menu items. |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::handle_row_actions() |
Generates and displays row action links. |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::column_title() |
Handles the title column output. |
wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::column_parent() |
Handles the parent column output. |
wp-admin/includes/post.php: wp_edit_attachments_query_vars() |
Get the query variables for the current attachments request. |
wp-admin/includes/export.php: export_wp() |
Generates the WXR export file for download. |
wp-admin/includes/deprecated.php: get_editable_user_ids() |
Gets the IDs of any users who can edit posts. |
wp-admin/includes/dashboard.php: wp_dashboard_right_now() |
Dashboard widget that displays some basic stats about the site. |
wp-admin/includes/dashboard.php: wp_dashboard_setup() |
Registers dashboard widgets. |
wp-admin/includes/template.php: get_inline_data() |
Adds hidden fields with the data for use in the inline editor for posts and pages. |
wp-admin/includes/media.php: get_media_item() |
Retrieve HTML form for modifying the image attachment. |
wp-admin/includes/post.php: _wp_post_thumbnail_html() |
Output HTML for the post thumbnail meta-box. |
wp-admin/includes/post.php: _admin_notice_post_locked() |
Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post. |
wp-admin/includes/post.php: wp_write_post() |
Creates a new post from the “Write Post” form using $_POST information. |
wp-admin/includes/post.php: get_sample_permalink() |
Get a sample permalink based off of the post name. |
wp-admin/includes/post.php: _wp_translate_postdata() |
Rename $_POST data from form names to DB post columns. |
wp-admin/includes/post.php: edit_post() |
Update an existing post with values provided in $_POST. |
wp-admin/includes/post.php: bulk_edit_posts() |
Process the post data for the bulk editing of posts. |
wp-admin/includes/ajax-actions.php: wp_ajax_query_attachments() |
Ajax handler for querying attachments. |
wp-admin/includes/ajax-actions.php: wp_ajax_add_menu_item() |
Ajax handler for adding a menu item. |
wp-admin/includes/meta-boxes.php: post_submit_meta_box() |
Displays post submit form fields. |
wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::column_response() | |
wp-admin/includes/class-wp-terms-list-table.php: WP_Terms_List_Table::column_posts() | |
wp-admin/includes/class-walker-nav-menu-edit.php: Walker_Nav_Menu_Edit::start_el() |
Start the element output. |
wp-admin/includes/nav-menu.php: _wp_ajax_menu_quick_search() |
Prints the appropriate response to a menu quick search. |
wp-admin/includes/nav-menu.php: wp_nav_menu_item_post_type_meta_box() |
Displays a meta box for a post type menu item. |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::inline_edit() |
Outputs the hidden row displayed when inline editing |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::no_items() | |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::get_bulk_actions() | |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::extra_tablenav() | |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::__construct() |
Constructor. |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::ajax_user_can() | |
wp-includes/capabilities.php: map_meta_cap() |
Maps meta capabilities to primitive capabilities. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::save() |
Handle customize_save WP Ajax request to save/update a changeset. |
wp-includes/category-template.php: wp_list_categories() |
Display or retrieve the HTML list of categories. |
wp-includes/general-template.php: feed_links_extra() |
Display the links to the extra feeds such as category feeds. |
wp-includes/general-template.php: wp_get_archives() |
Display archive links based on type and format. |
wp-includes/general-template.php: post_type_archive_title() |
Display or retrieve title for a post type archive. |
wp-includes/general-template.php: wp_title() |
Display or retrieve page title for all areas of blog. |
wp-includes/class-wp-query.php: WP_Query::get_queried_object() |
Retrieve queried object. |
wp-includes/class-wp-query.php: WP_Query::is_post_type_archive() |
Is the query for an existing post type archive page? |
wp-includes/class-wp-query.php: WP_Query::get_posts() |
Retrieves an array of posts based on query variables. |
wp-includes/class-wp-query.php: WP_Query::parse_query() |
Parse a query string and set query type booleans. |
wp-includes/taxonomy.php: register_taxonomy_for_object_type() |
Add an already registered taxonomy to an object type. |
wp-includes/taxonomy.php: unregister_taxonomy_for_object_type() |
Remove an already registered taxonomy from an object type. |
wp-includes/link-template.php: wp_get_shortlink() |
Returns a shortlink for a post, page, attachment, or site. |
wp-includes/link-template.php: get_adjacent_post() |
Retrieves the adjacent post. |
wp-includes/link-template.php: get_post_type_archive_link() |
Retrieves the permalink for a post type archive. |
wp-includes/link-template.php: get_post_type_archive_feed_link() |
Retrieves the permalink for a post type archive feed. |
wp-includes/link-template.php: get_edit_post_link() |
Retrieves the edit post link for post. |
wp-includes/link-template.php: get_delete_post_link() |
Retrieves the delete posts link for post. |
wp-includes/link-template.php: get_post_permalink() |
Retrieves the permalink for a post of a custom post type. |
wp-includes/admin-bar.php: wp_admin_bar_my_sites_menu() |
Add the “My Sites/[Site Name]” menu and all submenus. |
wp-includes/admin-bar.php: wp_admin_bar_edit_menu() |
Provide an edit link for posts and terms. |
wp-includes/template.php: get_post_type_archive_template() |
Retrieve path of post type archive template in current or parent template. |
wp-includes/media.php: wp_prepare_attachment_for_js() |
Prepares an attachment post object for JS, where it is expected to be JSON-encoded and fit into an Attachment model. |
wp-includes/media.php: wp_enqueue_media() |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
wp-includes/post.php: get_posts_by_author_sql() |
Retrieve the post SQL based on capability, author, and type. |
wp-includes/post.php: wp_insert_post() |
Insert or update a post. |
wp-includes/post.php: _count_posts_cache_key() |
Return the cache key for wp_count_posts() based on the passed arguments. |
wp-includes/post.php: wp_count_posts() |
Count number of posts of a post type and if user has permissions to view. |
wp-includes/post.php: _add_post_type_submenus() |
Add submenus for post types. |
wp-includes/post.php: is_post_type_hierarchical() |
Whether the post type is hierarchical. |
wp-includes/post.php: post_type_exists() |
Determines whether a post type is registered. |
wp-includes/canonical.php: redirect_canonical() |
Redirects incoming links to the proper URL based on the site url. |
wp-includes/ms-blogs.php: _update_blog_date_on_post_publish() |
Handler for updating the site’s last updated date when a post is published or an already published post is changed. |
wp-includes/ms-blogs.php: _update_blog_date_on_post_delete() |
Handler for updating the current site’s last updated date when a published post is deleted. |
wp-includes/nav-menu.php: wp_setup_nav_menu_item() |
Decorates a menu item object with the shared navigation menu item properties. |
wp-includes/nav-menu.php: wp_update_nav_menu_item() |
Save the properties of a menu item or create a new one. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::blogger_newPost() |
Creates new post. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::mw_newPost() |
Create a new post. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getPostType() |
Retrieves a post type |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getComments() |
Retrieve comments. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getPosts() |
Retrieve posts. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::_insert_post() |
Helper method for wp_newPost() and wp_editPost(), containing shared logic. |
wp-includes/class-wp-customize-control.php: WP_Customize_Control::render_content() |
Render the control’s content. |
User Contributed Notes #User Contributed Notes
You must log in before being able to contribute a note or feedback.
Examples
Technically, this is the same as
print_r( $obj )
might return something like this:Expand full source codeCollapse full source code
Assuming we have the post type ‘certification’, we could do this:
print_r( $obj )
might return something like this:Expand full source codeCollapse full source code
Note that the object’s attribute names are slightly different than the arguments expected for the
register_post_type()
function.