WP_Site_Icon::get_post_metadata() WordPress Method

The WP_Site_Icon::get_post_metadata() method is used to get the site icon for a given post. This can be used to get the site icon for a specific post, or to get the icon for the current post.

WP_Site_Icon::get_post_metadata( null|array|string $value, int $post_id, string $meta_key, bool $single ) #

Adds custom image sizes when meta data for an image is requested, that happens to be used as Site Icon.


Parameters

$value

(null|array|string)(Required)The value get_metadata() should return a single metadata value, or an array of values.

$post_id

(int)(Required)Post ID.

$meta_key

(string)(Required)Meta key.

$single

(bool)(Required)Whether to return only the first value of the specified $meta_key.


Top ↑

Return

(array|null|string) The attachment metadata value, array of values, or null.


Top ↑

Source

File: wp-admin/includes/class-wp-site-icon.php

	public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
		if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) {
			$site_icon_id = get_option( 'site_icon' );

			if ( $post_id == $site_icon_id ) {
				add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) );
			}
		}

		return $value;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.