get_post_types

Definition:
function get_post_types( $args = array() {}

Get a list of all registered post type objects.

Parameters

  • array|string $args: An array of key => value arguments to match against the post type objects.
  • string $output: The type of output to return, either post type ‘names’ or ‘objects’. ‘names’ is the default.
  • string $operator: The logical operation to perform. ‘or’ means only one element from the array needs to match; ‘and’ means all elements must match. The default is ‘and’.

Return values

returns:A list of post type names or objects

Source code

function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) {

	global $wp_post_types;



	$field = ('names' == $output) ? 'name' : false;



	return wp_filter_object_list($wp_post_types, $args, $operator, $field);

}

1626

get_post_type

Definition:
function get_post_type( $the_post = false ) {}

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

Parameters

  • mixed $the_post: Optional. Post object or post ID.

Return values

returns:post type or false on failure.

Source code

function get_post_type( $the_post = false ) {

	global $post;



	if ( false === $the_post )

		$the_post = $post;

	elseif ( is_numeric($the_post) )

		$the_post = get_post($the_post);



	if ( is_object($the_post) )

		return $the_post->post_type;



	return false;

}

1623

get_post_to_edit

Definition:
function get_post_to_edit( $id ) {}

Get an existing post and format it for editing.

Parameters

  • unknown_type $id

Source code

function get_post_to_edit( $id ) {



	$post = get_post( $id, OBJECT, 'edit' );



	if ( $post->post_type == 'page' )

		$post->page_template = get_post_meta( $id, '_wp_page_template', true );



	return $post;

}

1621

get_post_time

Definition:
function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp

Retrieve the time at which the post was written.

Parameters

  • string $d: Optional Either ‘G’, ‘U’, or php date format.
  • bool $gmt: Optional, default is false. Whether to return the gmt time.
  • int|object $post: Optional post ID or object. Default is global $post object.
  • bool $translate: Whether to translate the time string

Defined filters

  • get_post_time
    apply_filters('get_post_time', $time, $d, $gmt)

Source code

function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp

	$post = get_post($post);



	if ( $gmt )

		$time = $post->post_date_gmt;

	else

		$time = $post->post_date;



	$time = mysql2date($d, $time, $translate);

	return apply_filters('get_post_time', $time, $d, $gmt);

}

1619

get_post_thumbnail_id

Definition:
function get_post_thumbnail_id( $post_id = null ) {}

Retrieve Post Thumbnail ID.

Parameters

  • int $post_id: Optional. Post ID.

Source code

function get_post_thumbnail_id( $post_id = null ) {

	$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;

	return get_post_meta( $post_id, '_thumbnail_id', true );

}

1617