From 2fd5a470ff98922218bc067d23264a1cff438a13 Mon Sep 17 00:00:00 2001 From: Maxime Vanmeerbeck Date: Mon, 27 Nov 2017 12:30:33 +0100 Subject: [PATCH] title placeholders --- plugin.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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;