Cette extension n’a pas été testée avec plus de trois mises à jour majeures de WordPress. Elle peut ne plus être maintenue ou supportée et peut avoir des problèmes de compatibilité lorsqu’elle est utilisée avec des versions de WordPress plus récentes.

WP REST Yoast Meta

Description

This plugin is no longer updated, but is open for adoption
As of Yoast SEO version 16.7 the functionality provided by this plugin is now part of the Yoast SEO plugin itself. This plugin will no longer be updated, but is open for adoption. If you are interested in adopting this plugin, please contact the authors.

Utilisez-vous WordPress dans une configuration headless, à l’aide de l’API WP REST ? Et aimeriez-vous utiliser l’extension Yoast SEO comme vous le feriez pour tout autre projet ? Cette extension ajoute les balises méta générées par Yoast SEO à la sortie de l’API WP REST, permettant ainsi à votre configuration headless de les implémenter. De plus, lorsque vous utilisez Yoast SEO Premium, vous avez la possibilité de récupérer les redirections via l’API : cette extension ajoute un point de terminaison personnalisé (/wp-rest-yoast-meta/v1/redirects) pour fournir ces redirections au format JSON. Depuis Yoast 11.0 JSON LD les données Schema.org sont également prises en charge et sont également disponibles via l’API WP REST lors de l’utilisation de cette extension.

Installation depuis WordPress

  1. Visit ‘Plugins > Add New’ (or ‘My Sites > Network Admin > Plugins > Add New’ if you are on a multisite installation).
  2. Recherchez « WP REST Yoast Meta ».
  3. Activez l’extension WP REST Yoast Meta via le menu « Extensions » de WordPress.

Installation manuelle

  1. Upload the wp-rest-yoast-meta folder to the /wp-content/plugins/ directory.
  2. Activez l’extension WP REST Yoast Meta via le menu « Extensions » de WordPress.

Captures d’écran

  • La sortie de l’API REST de WP pour l’exemple d’article Hello World.

FAQ

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?

Cette extension ajoute un point de terminaison personnalisé (/wp-rest-yoast-meta/v1/home) pour récupérer la méta Yoast pour la page d’accueil.

Je ne veux pas que la méta Yoast soit appliquée au type de publication X, puis-je empêcher son ajout ?

Oui, vous pouvez ! Utilisez le crochet wp_rest_yoast_meta/filter_post_types comme ceci :

/**
 * 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 );

Avis

31 décembre 2019
Install, activate, and boom… instantly started seeing all of the SEO by Yoast fields in my JSON responses.
31 octobre 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.
Lire les 6 avis

Contributeurs/contributrices & développeurs/développeuses

« WP REST Yoast Meta » est un logiciel libre. Les personnes suivantes ont contribué à cette extension.

Contributeurs

“WP REST Yoast Meta” a été traduit dans 2 locales. Remerciez l’équipe de traduction pour ses contributions.

Traduisez « WP REST Yoast Meta » dans votre langue.

Le développement vous intéresse ?

Parcourir le code, consulter le SVN dépôt, ou s’inscrire au journal de développement par RSS.

Journal

2021.1.2

Release Date: July 1st, 2021

Bugfix: The yoast_title wasn’t set correctly for consecutive posts in an overview request.

2021.1.1

Release Date: April 20th, 2021

Bugfix: As of WordPress 5.7.0 the robots meta doesn’t come from Yoast SEO, but from WP Core.
Bugfix: The yoast meta doesn’t include the tag anymore, retrieve it differently.

2021.1.0

Release Date: January 7th, 2021

Bugfix: Do not call deprecated wpseo_frontend_head_init function.

2020.2.2

Release Date: September 7th, 2020

Bugfix: permission_callback notice as of WordPress 5.5.

2020.2.1

Release Date: June 8th, 2020

Bugfix: Minor fix to the redirects endpoint.

2020.2.0

Release Date: April 30th, 2020

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

2020.1.0

Release Date: January 16th, 2020

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

2019.5.3

Release Date: December 12th, 2019

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

2019.5.2

Release Date: November 22nd, 2019

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

2019.5.1

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.

2019.5.0

Release Date: October 29th, 2019

Feature: Added custom endpoint for retrieving homepage Yoast meta.

2019.4.2

Release Date: October 20th, 2019

Bugfix: Transients shouldn’t be set without expiration.

2019.4.1

Release Date: October 18th, 2019

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

2019.4.0

Release Date: October 17th, 2019

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

2019.3.0

Release Date: October 15th, 2019

Bugfix: Improved HTML parsing using DOMDocument.

2019.2.1

Release Date: June 27th, 2019

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

2019.2.0

Release Date: June 16th, 2019

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

2019.1.0

Release Date: March 6th, 2019

First public version.