WP_Post::filter( string $filter ): WP_Post|false

Applies the provided context filter for the current post.

Description

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.

Parameters

$filterstringrequired
Filter.

Return

WP_Post|false

Source

public function filter( $filter ) {
	if ( $this->filter === $filter ) {
		return $this;
	}

	if ( 'raw' === $filter ) {
		return self::get_instance( $this->ID );
	}

	return sanitize_post( $this, $filter );
}

Changelog

VersionDescription
3.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.