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
I tried to use the mentioned hook but didnt have any success an example would be nice thanks
The text was updated successfully, but these errors were encountered:
Hey @Metin-Ljapo,
Here's how I used the hooks in V2. In my custom WordPress plugin, I added this code
// Add ACF Image Field to Menu Item endpoint (eg /wp-api-menus/v2/menus/:id items[]) add_filter('rest_menus_format_menu_item', 'add_acf_to_menu_item', 100, 1); if (!function_exists('add_acf_to_menu_item')) { function add_acf_to_menu_item($item) { $acf_field = get_field( 'Image_Field', $item['id'] ); $item['acf'] = $acf_field; return $item; } } // 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; } }
There's a 3rd hook in V2, which is rest_menus_format_menus to alter the list of menu items returned (e.g from wp-json/wp-api-menus/v2/menus/)
rest_menus_format_menus
wp-json/wp-api-menus/v2/menus/
Sorry, something went wrong.
No branches or pull requests
I tried to use the mentioned hook but didnt have any success an example would be nice thanks
The text was updated successfully, but these errors were encountered: