WP_Post::to_array()publicWP 3.5.0

Convert object to array.

Method of the class: WP_Post{}

No Hooks.

Return

Array. Object as array.

Usage

$WP_Post = new WP_Post();
$WP_Post->to_array();

Changelog

Since 3.5.0 Introduced.

WP_Post::to_array() code WP 6.5.2

public function to_array() {
	$post = get_object_vars( $this );

	foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) {
		if ( $this->__isset( $key ) ) {
			$post[ $key ] = $this->__get( $key );
		}
	}

	return $post;
}