WP_Post::filter
Applies the provided context filter for the current post.
If the requested filter was already applied, then it returns without any changes.
If the 'raw' filter is supplied, then a new instance of the post is obtained and this method _may_ return false in case the underlying post was deleted.
Method of the class: WP_Post{}
No Hooks.
Returns
WP_Post|false.
Usage
$WP_Post = new WP_Post(); $WP_Post->filter( $filter );
- $filter(string) (required)
- Filter.
Changelog
| Since 3.5.0 | Introduced. |
WP_Post::filter() WP Post::filter code WP 7.1
public function filter( $filter ) {
if ( $this->filter === $filter ) {
return $this;
}
if ( 'raw' === $filter ) {
return self::get_instance( $this->ID );
}
return sanitize_post( $this, $filter );
}