ap_get_post_field( string $field, mixed $_post = null )

Description #

Get a specific post field.

Parameters #

  • $field
    string (Required) Post field name.
  • $_post
    mixed (Optional) Post ID, Object or null. Default value: null

Changelog #

VersionDescription
4.1.5Introduced.

Source #

File: includes/qameta.php

function ap_get_post_field( $field, $_post = null ) {
	$_post = ap_get_post( $_post );

	if ( isset( $_post->$field ) ) {
		// Serialize if fields column.
		if ( 'fields' === $field ) {
			return maybe_unserialize( $_post->$field );
		}

		return $_post->$field;
	}

	return '';
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment