get_post_type( int|WP_Post|null $post = null )
Retrieves the post type of the current post or of a given post.
Parameters
- $post
-
(int|WP_Post|null) (Optional) Post ID or post object. Default is global $post.
Default value: null
Return
(string|false) Post type on success, false on failure.
Source
File: wp-includes/post.php
function get_post_type( $post = null ) {
if ( $post = get_post( $post ) )
return $post->post_type;
return false;
}
Related
Uses
Uses | Description |
---|---|
wp-includes/post.php: get_post() |
Retrieves post data given a post ID or post object. |
Used By
Used By | Description |
---|---|
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::create_item() |
Creates a single attachment. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::update_item() |
Updates a single attachment. |
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/widgets/class-wp-widget-media.php: WP_Widget_Media::has_content() |
Whether the widget has content to show. |
wp-includes/widgets/class-wp-widget-media-gallery.php: WP_Widget_Media_Gallery::has_content() |
Whether the widget has content to show. |
wp-includes/nav-menu.php: is_nav_menu_item() |
Determines whether the given ID is a nav menu item. |
wp-includes/class-wp-embed.php: WP_Embed::find_oembed_post_id() |
Find the oEmbed cache post ID for a given cache key. |
wp-includes/embed.php: get_oembed_response_data_rich() |
Filters the oEmbed response data to return an iframe embed code. |
wp-includes/ms-blogs.php: _update_posts_count_on_transition_post_status() |
Handler for updating the current site’s posts count when a post status changes. |
wp-includes/meta.php: get_object_subtype() |
Returns the object subtype for a given object ID of a specific type. |
wp-includes/class-wp-theme.php: WP_Theme::get_page_templates() |
Returns the theme’s post templates for a given post type. |
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/category-template.php: get_the_category_list() |
Retrieve category list for a post in either HTML list or custom format. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::has_published_pages() |
Return whether there are published pages. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::find_changeset_post_id() |
Find the changeset post ID for a given changeset UUID. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::get_changeset_post_data() |
Get the data stored in a changeset post. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::preserve_insert_changeset_post_content() |
Preserve the initial JSON post_content passed to save into the post. |
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/post.php: wp_check_for_changed_slugs() |
Check for changed slugs for published post objects and save the old slug. |
wp-includes/post.php: wp_check_for_changed_dates() |
Check for changed dates for published post objects and save the old date. |
wp-includes/post.php: wp_set_post_categories() |
Set categories for a post. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::save_nav_menus_created_posts() |
Publish the auto-draft posts that were created for nav menu items. |
wp-admin/includes/media.php: get_media_item() |
Retrieve HTML form for modifying the image attachment. |
wp-admin/includes/nav-menu.php: _wp_ajax_menu_quick_search() |
Prints the appropriate response to a menu quick search. |
wp-admin/includes/post.php: bulk_edit_posts() |
Process the post data for the bulk editing of posts. |
Changelog
Version | Description |
---|---|
WP-2.1.0 | Introduced. |