REST API + Polylang

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

"... none of the offered feeds [RSS does - mine] seem to include information on the language of the content...."

"It is because Frédéric, polylang’s author has not set his taxonomy property ‘show_in_rest’ => true ..."

"The plugin author is not planning to add this to the free version. The pro version will get something that could provide for this..."

function wpse_modify_taxonomy() {
    // get the arguments of the already-registered taxonomy
    $language_args = get_taxonomy( 'language' ); // returns an object

    // make changes to the args
    // in this example there are three changes
    // again, note that it's an object
    $language_args->show_in_rest = true;

    // re-register the taxonomy
    register_taxonomy( 'language', 'post', (array) $language_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'wpse_modify_taxonomy', 11 );

It could be slow, it could be something else, but it works.

Source: How to know the language of a post through the WordPress REST API | WordPress.org

Yandex.Metrica