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.
Parameters
- $name
(string)(Required)
Return
(mixed)
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;
}
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |