diff --git a/plugin.php b/plugin.php index 5ea78f1..bacf997 100644 --- a/plugin.php +++ b/plugin.php @@ -97,8 +97,15 @@ function wp_api_encode_yoast( $post, $field_name, $request ) { $this->keys[] = 'yoast_wpseo_primary_' . $taxonomy; } + $frontend = WPSEO_Frontend::get_instance(); + $object = get_post($post['id']); + foreach ($this->keys as $key) { - $yoastMeta[$key] = get_post_meta($post['id'], '_' . $key, true); + if ('yoast_wpseo_title' === $key) { + $yoastMeta[$key] = $frontend->get_content_title($object); + } else { + $yoastMeta[$key] = get_post_meta($post['id'], '_' . $key, true); + } } return (array) $yoastMeta;