diff --git a/json-endpoints/jetpack/class.jetpack-json-api-get-post-backup-endpoint.php b/json-endpoints/jetpack/class.jetpack-json-api-get-post-backup-endpoint.php index 903a16ac8fbd5..7e7ff2a7f7767 100644 --- a/json-endpoints/jetpack/class.jetpack-json-api-get-post-backup-endpoint.php +++ b/json-endpoints/jetpack/class.jetpack-json-api-get-post-backup-endpoint.php @@ -17,14 +17,22 @@ function validate_input( $post_id ) { } protected function result() { + global $wpdb; + $post = get_post( $this->post_id ); if ( empty( $post ) ) { return new WP_Error( 'post_not_found', __( 'Post not found', 'jetpack' ), 404 ); } + // Fetch terms associated with this post object + $terms = $wpdb->get_results( $wpdb->prepare( + "SELECT term_taxonomy_id, term_order FROM {$wpdb->term_relationships} WHERE object_id = %d;", $post->ID + ) ); + return array( - 'post' => (array)$post, - 'meta' => get_post_meta( $post->ID ), + 'post' => (array)$post, + 'meta' => get_post_meta( $post->ID ), + 'terms' => (array)$terms, ); } diff --git a/json-endpoints/jetpack/json-api-jetpack-endpoints.php b/json-endpoints/jetpack/json-api-jetpack-endpoints.php index 15a1731920c6e..36d5a67cacf7c 100644 --- a/json-endpoints/jetpack/json-api-jetpack-endpoints.php +++ b/json-endpoints/jetpack/json-api-jetpack-endpoints.php @@ -1061,8 +1061,9 @@ '$post' => '(int) The post ID', ), 'response_format' => array( - 'post' => '(array) Post table row', - 'meta' => '(array) Associative array of key/value postmeta data', + 'post' => '(array) Post table row', + 'meta' => '(array) Associative array of key/value postmeta data', + 'terms' => '(array) List of terms attached to the post object', ), 'example_request_data' => array( 'headers' => array(