wp_get_post_terms

Definition:
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() {}

Retrieve the terms for a post.
There is only one default for this function, called ‘fields’ and by default is set to ‘all’. There are other defaults that can be overridden in wp_get_object_terms().

Parameters

  • int $post_id: Optional. The Post ID
  • string $taxonomy: The taxonomy for which to retrieve terms. Defaults to post_tag.
  • array $args: Optional. Overwrite the defaults

Return values

returns:List of post tags.

Source code

function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {

	$post_id = (int) $post_id;



	$defaults = array('fields' => 'all');

	$args = wp_parse_args( $args, $defaults );



	$tags = wp_get_object_terms($post_id, $taxonomy, $args);



	return $tags;

}

3739

wp_get_post_revisions

Definition:
function wp_get_post_revisions( $post_id = 0, $args = null ) {}

Returns all revisions of specified post.

Parameters

  • int|object $post_id: Post ID or post object
  • $args

Return values

returns:empty if no revisions

Source code

function wp_get_post_revisions( $post_id = 0, $args = null ) {

	if ( ! WP_POST_REVISIONS )

		return array();

	if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) )

		return array();



	$defaults = array( 'order' => 'DESC', 'orderby' => 'date' );

	$args = wp_parse_args( $args, $defaults );

	$args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );



	if ( !$revisions = get_children( $args ) )

		return array();

	return $revisions;

}

3735

wp_get_post_revision

Definition:
function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {}

Gets a post revision.

Parameters

  • int|object $post: Post ID or post object
  • string $output: Optional. OBJECT, ARRAY_A, or ARRAY_N.
  • string $filter: Optional sanitation filter. @see sanitize_post()
  • &$post

Return values

returns:Null if error or post object if success

Source code

function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {

	$null = null;

	if ( !$revision = get_post( $post, OBJECT, $filter ) )

		return $revision;

	if ( 'revision' !== $revision->post_type )

		return $null;



	if ( $output == OBJECT ) {

		return $revision;

	} elseif ( $output == ARRAY_A ) {

		$_revision = get_object_vars($revision);

		return $_revision;

	} elseif ( $output == ARRAY_N ) {

		$_revision = array_values(get_object_vars($revision));

		return $_revision;

	}



	return $revision;

}

3733

wp_get_post_cats

Definition:
function wp_get_post_cats($blogid = '1', $post_ID = 0) {}

Parameters

  • int $blogid: Not Used
  • int $post_ID

Source code

function wp_get_post_cats($blogid = '1', $post_ID = 0) {

	_deprecated_function( __FUNCTION__, '2.1', 'wp_get_post_categories()' );

	return wp_get_post_categories($post_ID);

}

3731