WP_Post::__isset() WordPress Method

The WP_Post::__isset() method is used to check if a certain post property exists. This is useful for checking if a post has a certain custom field set, for example.

WP_Post::__isset( string $key ) #

Isset-er.


Parameters

$key

(string)(Required)Property to check if set.


Top ↑

Return

(bool)


Top ↑

Source

File: wp-includes/class-wp-post.php

	public function __isset( $key ) {
		if ( 'ancestors' === $key ) {
			return true;
		}

		if ( 'page_template' === $key ) {
			return true;
		}

		if ( 'post_category' === $key ) {
			return true;
		}

		if ( 'tags_input' === $key ) {
			return true;
		}

		return metadata_exists( 'post', $this->ID, $key );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.5.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.