WP_Post::__construct() WordPress Method
The WP_Post::__construct() method initializes a new post object. It accepts an post ID or a post object as its first parameter. If you pass an post ID, the method will retrieve the post data from the database and populate the object properties. If you pass an post object, the method will simply set the object properties.
WP_Post::__construct( WP_Post|object $post ) #
Constructor.
Parameters
- $post
(WP_Post|object)(Required)Post object.
Source
File: wp-includes/class-wp-post.php
public function __construct( $post ) { foreach ( get_object_vars( $post ) as $key => $value ) { $this->$key = $value; } }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |