WP_Post::to_array() WordPress Method
The WP_Post::to_array() method is used to convert a WP_Post object into an array. This is useful for manipulating post data in an external application or for debugging.
WP_Post::to_array() #
Convert object to array.
Return
(array) Object as array.
Source
File: wp-includes/class-wp-post.php
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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |