A_Z_Listing::get_item_meta( string $key = '', bool $single = false )

Retrieve meta field for an item.


Description


Parameters

$key

(string) (Optional) The meta key to retrieve. By default returns data for all keys.

Default value: ''

$single

(bool) (Optional) Whether to return a single value.

Default value: false


Return

(mixed) Will be an array if $single is false. Will be value of meta data field if $single is true.


Source

File: classes/class-a-z-listing.php

	function get_item_meta( $key = '', $single = false ) {
		if ( is_string( $this->current_item['item'] ) ) {
			$item = explode( ':', $this->current_item['item'], 2 );

			if ( 'term' === $type[0] ) {
				return get_term_meta( $item[1], $key, $single );
			}

			return get_post_meta( $item[1], $key, $single );
		}

		if ( is_a( $this->current_item['item'], 'WP_Term' ) ) {
			return get_term_meta( $this->current_item['item']->term_id, $key, $single );
		}

		return get_post_meta( $this->current_item['item']->ID, $key, $single );
	}

Changelog

Changelog
VersionDescription
2.1.0Introduced.

User Contributed Notes

Leave a Reply

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