Open laustdeleuran opened 7 years ago
Yes that would be nice, now you must find correct navi ID and get this navi by ID
Hey @laustdeleuran and @isuke01, I came across the same thing earlier today! I'm using V2 of this plugin. Here's how I solved it.
// Add Locale to Menu endpoint (eg /wp-api-menus/v2/menus/:id )
add_filter('rest_menus_format_menu', 'add_locale_to_menu', 100, 1);
if (!function_exists('add_locale_to_menu')) {
function add_locale_to_menu($rest_menu) {
$args = array('element_id' => $rest_menu['ID'], 'element_type' => 'nav_menu' );
$rest_menu['locale'] = apply_filters( 'wpml_element_language_code', null, $args );
return $rest_menu;
}
}
Would love to use /wp-api-menus/v2/menus?lang=en
when you get a chance. Is it in the roadmap?
WP-API supports WPML out of the box, so API queries with the parameter
lang=CODE
or similar just works. This doesn't seem to work in this plugin. Are there any plans to implement this support or am I missing some way it's already implemented?