WP REST Yoast Meta

Mô tả

Are you using WordPress for a headless set-up, using the WP REST API? And would you like to use the Yoast SEO plugin just like you would for any other project? This plugin adds the meta tags generated by the Yoast SEO plugin to the WP REST API output, allowing your headless set-up to implement them. Also when you are using Yoast SEO Premium you have the option to retrieve redirects throught the API: this plugin adds a custom endpoint (/wp-rest-yoast-meta/v1/redirects) to provide those redirects in a JSON format. Since Yoast 11.0 JSON LD Schema.org data is also supported and is now also available through the WP REST API when using this plugin.

Installation from within WordPress

  1. Visit ‘Plugins > Add New’ (or ‘My Sites > Network Admin > Plugins > Add New’ if you are on a multisite installation).
  2. Search for ‘WP REST Yoast Meta’.
  3. Activate the WP REST Yoast Meta plugin through the ‘Plugins’ menu in WordPress.

Installation manually

  1. Upload the wp-rest-yoast-meta folder to the /wp-content/plugins/ directory.
  2. Activate the WP REST Yoast Meta plugin through the ‘Plugins’ menu in WordPress.

Ảnh màn hình

  • The WP REST API output for the Hello World post example.

Hỏi đáp

I have installed the plugin, where can I find the Yoast meta tags?

For each post/page/… you can find an array of meta tags in that object under yoast_meta.

I have installed the plugin, where can I find the Yoast JSON LD Schema.org data?

For each post/page/… you can find an array of JSON LD data in that object under yoast_json_ld.

I have created a custom post type, will the plugin add the meta tags to that post type?

Yes, the plugin will automatically add meta tags to custom post types. Unless you have created a custom WP_REST_Controller for it and have not implemented the rest_prepare_POSTTYPE filter.

Can I add my own meta tags?

Yes you can! Use the hook wp_rest_yoast_meta/filter_yoast_meta like this:

 * Add a custom meta tag.
function wpym_add_custom_meta_tag( $yoast_meta ) {
    $yoast_meta[] = array(
        'property' => 'og:type',
        'content' => 'article'
    return $yoast_meta;
add_filter( 'wp_rest_yoast_meta/filter_yoast_meta', 'wpym_add_custom_meta_tag', 10, 1);

I have the Yoast SEO Premium plugin installed, will it work?

Yes this plugin supports both the free and the premium version of Yoast SEO. Please keep in mind that the free version of Yoast SEO does not allow you to specify redirects, so the redirects endpoint will return an empty set.

I have set the homepage to display my latest posts, how do I get the Yoast meta for the homepage?

This plugin adds a custom endpoint (/wp-rest-yoast-meta/v1/home) to retrieve the Yoast meta for the homepage.

I don’t want the Yoast Meta to be applied to post type X, can I stop it from being added?

Yes you can! Use the hook wp_rest_yoast_meta/filter_post_types like this:

 * Remove Yoast Meta from the page post type
function wpym_remove_post_type( $post_types ) {
    foreach ( $post_types as $key => $post_type ) {
        if ( 'page' === $post_type->name ) {
            unset( $post_types[ $key ] );

    return $post_types;

add_filter( 'wp_rest_yoast_meta/filter_post_types', 'wpym_remove_post_type', 10, 1 );

Đánh giá

11 Tháng Chín, 2020
Thank you! This plugin helped me to get all the Yoast meta data in JSON format, so I can use it in my website build with React in combination with Headless WordPress.
31 Tháng Mười Hai, 2019
Install, activate, and boom... instantly started seeing all of the SEO by Yoast fields in my JSON responses.
31 Tháng Mười, 2019
Must Have for applications using WordPress as headless CMS. Much better to make use of the existing Yoast SEO settings. Thanks for this plugin for making it available on the REST API.
Đọc tất cả 6 đánh giá

Người đóng góp & Lập trình viên

“WP REST Yoast Meta” là mã nguồn mở. Những người sau đã đóng góp vào plugin này.

Những người đóng góp

“WP REST Yoast Meta” đã được dịch qua 1 ngôn ngữ. Cảm ơn những người tham gia dịch vì đóng góp của họ.

Dịch “WP REST Yoast Meta” sang ngôn ngữ của bạn.

Muốn tham gia phát triển?

Duyệt code, check out SVN repository, hoặc theo dõi nhật ký phát triển qua RSS.

Nhật ký thay đổi


Release Date: September 7th, 2020

Bugfix: permission_callback notice as of WordPress 5.5.


Release Date: June 8th, 2020

Bugfix: Minor fix to the redirects endpoint.


Release Date: April 30th, 2020

Bugfix: Added support for Yaost SEO 14.0, which has done an extensive rebuild of code.


Release Date: January 16th, 2020

Bugfix: Fix for custom post types that are registered later in the initialisation process.


Release Date: December 12th, 2019

Bugfix: Fix notice.
Bugfix: Proper escaping of special characters.


Release Date: November 22nd, 2019

Bugfix: Check for at least Yoast SEO 11.* for specific functionality.
Feature: Added seperate yoast_title attribute.


Release Date: November 7th, 2019

Feature: Added filter to be able to remove yoast meta from post types.
Bugfix: Fix multiplication of json-ld data.
Bugfix: Make sure Twitter meta image displays correct image.
Bugfix: Fix homepage endpoint not updating.


Release Date: October 29th, 2019

Feature: Added custom endpoint for retrieving homepage Yoast meta.


Release Date: October 20th, 2019

Bugfix: Transients shouldn’t be set without expiration.


Release Date: October 18th, 2019

Bugfix: fix inconsistency between DOMDocument and simplexml in parsing json ld data.


Release Date: October 17th, 2019

Feature: Added Yoast SEO’s JSON LD Schema.org data to the WP REST API.


Release Date: October 15th, 2019

Bugfix: Improved HTML parsing using DOMDocument.


Release Date: June 27th, 2019

Bugfix: Yoast meta wasn’t regenerated correctly after a post update.


Release Date: June 16th, 2019

Improvement: Meet WordPress Coding Standards.
Bugfix: Better check if Yoast SEO (Premium) is installed and activated.


Release Date: March 6th, 2019

First public version.