Base::from_post( WP_Post|int $post )
Builds, and returns, a post type model from a given post.
Contents
Parameters
- $post
-
(WP_Post|int) (Required) The post ID or post object.
Return
(TribeModelsPost_TypesBase|TribeModelsPost_TypesNothing) Either the built Post Type model, or a Nothing model if the post does not exist.
Source
File: src/Tribe/Models/Post_Types/Base.php
public static function from_post( $post ) {
$post = get_post( $post );
if ( ! $post instanceof \WP_Post ) {
return new Nothing();
}
$instance = new static;
$instance->post = $post;
return $instance;
}
Changelog
| Version | Description |
|---|---|
| 4.9.18 | Introduced. |