WordPress at a glance

get_post_type() WP 1.0

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

Works based on: get_post()
✈ 1 time = 0.000637s = slow | 50000 times = 0.17s = very fast PHP 7.1.2, WP 4.7.5

No Hooks.

Return

String/false. Post type on success, false on failure.

Usage

get_post_type( $post );
$post(int/WP_Post/null)
Post ID or post object.
Default: global $post

Code of get_post_type: wp-includes/post.php VER 4.9.8

<?php
function get_post_type( $post = null ) {
	if ( $post = get_post( $post ) )
		return $post->post_type;

	return false;
}

Related Functions

From tag: Custom post type (post_type)

More from category: Custom Types

No comments
    Hello, !     Log In . Register