We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hi,
first thanks for your awesome plugin! Saves me a lot of time when i have to manage Multilingual websites.
Is there a way to register translations when calling Wordpress Rest API?
Below is my attempt at doing something beyond my expertise ^^
/* https://domain.com/en/wp-json/wp/v2/post/id */ function register_mls_for_rest_api() { register_rest_field( 'post', 'mls_translations', array( 'get_callback' => 'get_mls_translations', 'update_callback' => null, 'schema' => null, ) ); } add_action( 'rest_api_init', 'register_mls_for_rest_api' ); function get_mls_translations() $object, $field_name, $request ) { // this is where i'm stuck... // $lang_array = where_im_stuck('-_-'); // $hreflang = $lang_array['0']; // $href = $lang_array['1']; // return array( // $hreflang => $href, // ); }
The text was updated successfully, but these errors were encountered:
Hey looks good. I guess you should return the values using rest_ensure_response(). What are the values that you want to have in $lang_array?
rest_ensure_response()
$blog = MslsBlogCollection::instance()->get_current_blog(); $language = $blog->get_language(); // en_US $alpha2 = $blog->get_alpha2(); // en
or
$arr = []; foreach ( MslsBlogCollection::instance()->get() as $blog ) { $arr[] = $blog->get_language(); }
?
Read on here: https://msls.co/developer-docs/snippets-examples/
Sorry, something went wrong.
No branches or pull requests
hi,
first thanks for your awesome plugin! Saves me a lot of time when i have to manage Multilingual websites.
Is there a way to register translations when calling Wordpress Rest API?
Below is my attempt at doing something beyond my expertise ^^
The text was updated successfully, but these errors were encountered: