Reference › Functions get_post_type ( int | WP_Post| null $post = null ): string | false
Since 2.1.0
Source wp-includes/post.php:1596Parameters Return Uses Used by Source History Retrieves the post type of the current post or of a given post.
Parameters
$postint | WP_Post| nulloptional Post ID or post object. Default is global $post.Default: null Return
string | falsePost type on success, false on failure. Uses · 1 get_post() Retrieves post data given a post ID or post object. Used by · 49 Show all 49 WP_REST_Posts_Controller::prepare_item_for_database() Prepares a single post for create or update. WP_Theme::get_page_templates() Returns the theme's post templates for a given post type. WP_Widget_Media::has_content() Whether the widget has content to show. WP_Widget_Media_Gallery::has_content() Whether the widget has content to show. _disable_content_editor_for_navigation_post_type() This callback disables the content editor for wp_navigation type posts. _enable_content_editor_for_navigation_post_type() This callback enables content editor for wp_navigation type posts. _update_posts_count_on_transition_post_status() Handler for updating the current site's posts count when a post status changes. _wp_ajax_menu_quick_search() Prints the appropriate response to a menu quick search. block_core_calendar_update_has_published_post_on_transition_post_status() Handler for updating the has published posts flag when a post status changes. bulk_edit_posts() Processes the post data for the bulk editing of posts. get_attachment_link() Retrieves the permalink for an attachment. get_media_item() Retrieves HTML form for modifying the image attachment. get_object_subtype() Returns the object subtype for a given object ID of a specific type. get_oembed_response_data_rich() Filters the oEmbed response data to return an iframe embed code. get_the_category_list() Retrieves category list for a post in either HTML list or custom format. is_nav_menu_item() Determines whether the given ID is a nav menu item. is_post_publicly_viewable() Determines whether a post is publicly viewable. render_block_core_post_template() Renders the `core/post-template` block on the server. render_block_core_query_title() Renders the `core/query-title` block on the server. render_block_core_video() Renders the `core/video` block on the server to supply the width and height attributes from the attachment metadata. twenty_twenty_one_entry_meta_footer() Prints HTML with meta information for the categories, tags and comments. twenty_twenty_one_posted_by() Prints HTML with meta information about theme author. twentyfifteen_entry_meta() Prints HTML with meta information for the categories, tags. twentynineteen_entry_footer() Prints HTML with meta information for the categories, tags and comments. twentyseventeen_entry_footer() Prints HTML with meta information for the categories, tags and comments. twentysixteen_content_image_sizes_attr() Adds custom image sizes attribute to enhance responsive image functionality for content images twentysixteen_entry_meta() Prints HTML with meta information for the categories, tags. twentyten_posted_in() Prints HTML with meta information for the current post (category, tags and permalink). twentythirteen_entry_meta() Prints HTML with meta information for current post: categories, tags, permalink, author, and date. twentytwenty_get_post_meta() Retrieves the post meta. wp_autosave_post_revisioned_meta_fields() Autosaves the revisioned meta fields. wp_force_plain_post_permalink() Determine whether post should always use a plain permalink structure. wp_get_post_content_block_attributes() Retrieves Post Content block attributes from the current post template. wp_restore_post_revision_meta() Restore the revisioned meta values for a post. wp_save_revisioned_meta_fields() Save the revisioned meta fields. wp_set_post_categories() Sets categories for a post. wp_xmlrpc_server::_insert_post() Helper method for wp_newPost() and wp_editPost(), containing shared logic. Source View on Trac ↗ View on GitHub ↗
1596 function get_post_type ( $post = null ) { 1597 $post = get_post ( $post ) ; 1598 if ( $post ) { 1599 return $post -> post_type ; 1600 } 1601 1602 return false ; 1603 } History Introduced in 2.1.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/post.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.