WP_Comment::__get() WordPress Method

The WP_Comment::__get() method allows developers to access comment data for a specific comment. This is useful for retrieving data for a specific comment, such as the comment author or comment content.

WP_Comment::__get( string $name ) #

Magic getter.


Description

If $name matches a post field, the comment post will be loaded and the post’s value returned.


Top ↑

Parameters

$name

(string)(Required)


Top ↑

Return

(mixed)


Top ↑

Source

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

	public function __get( $name ) {
		if ( in_array( $name, $this->post_fields, true ) ) {
			$post = get_post( $this->comment_post_ID );
			return $post->$name;
		}
	}


Top ↑

Changelog

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