Codex

Function Reference/get post type

Contents

Description

Retrieve the post type of the current post or of a given post.

Usage

<?php echo get_post_type$post ?>

Parameters

$post
(mixed) (optional) Post object or post ID.
Default: false

Return Values

(boolean|string) 
post type or false on failure.

Examples

Display the post type. This example needs to be inside the loop.

<?php echo 'The post type is: '.get_post_type( get_the_ID() ); ?>

Notes

  • Uses: $post The Loop current post global

Change Log

Since: 2.1.0

Source File

get_post_type() is located in wp-includes/post.php.

Related

Post Types: register_post_type(), add_post_type_support(), remove_post_type_support(), post_type_supports(), post_type_exists(), set_post_type(), get_post_type(), get_post_types(), get_post_type_object(), get_post_type_capabilities(), get_post_type_labels(), is_post_type_hierarchical(), is_post_type_archive(), post_type_archive_title()

See also index of Function Reference and index of Template Tags.