Title: children hook
Last modified: August 24, 2016

---

# children hook

 *  Resolved [Jack Dunstan](https://wordpress.org/support/users/batmanian/)
 * (@batmanian)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/children-hook/)
 * Hi, great plugin.
 * I’m at a loss on how to implement the filter hook to format children menu items.
   I’ve built [an example](http://codepen.io/Batmanian/pen/LVGdEN) but am unable
   to parse the children differently.
 * I understand this is the correct filter hook.
 * json_menus_format_menu_item
 * I’m a JSON noob – any direction or examples on how to achieve this would be greatly
   appreciated.
 * Thanks
 * [https://wordpress.org/plugins/wp-api-menus/](https://wordpress.org/plugins/wp-api-menus/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Fulvio Notarstefano](https://wordpress.org/support/users/nekojira/)
 * (@nekojira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/children-hook/#post-6119150)
 * Hello Batmanian,
 * if you create a filter for that hook, you can pass as the argument the data to
   filter
 * example:
 *     ```
       add_filter( 'json_menus_format_menu_item', 'my_menu_filter', 1 );
   
       function my_menu_filter( $menu_data ) {
           var_dump($menu_data);
           // do something with $menu_data
           return $menu_data;
       }
       ```
   
 * `$menu_data` is an array that contains the information that will be fed to WP
   API – if you want to manipulate this data you can do it in your custom filter
   callback – you need to make sure that $menu_data is a valid PHP array, it will
   be encoded to JSON by WP API
 * I’m not sure how you are retrieving the JSON data but if you have put a filter
   in place, it will be formatted the way you want and the data will be returned
   at the routes provided by the plugin – the output of course is a JSON object:
   you can treat a JSON object like a Javascript object and use the data in each
   of its nodes accordingly – strings, arrays, numbers, bool…
 *  Thread Starter [Jack Dunstan](https://wordpress.org/support/users/batmanian/)
 * (@batmanian)
 * [11 years ago](https://wordpress.org/support/topic/children-hook/#post-6119398)
 * Hi,
 * Thanks for the insight. I’ll do some reading on filters and get to work.
 *  [Goharika](https://wordpress.org/support/users/goharika/)
 * (@goharika)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/children-hook/#post-6119417)
 * Hi,
    Great plugin, can easily get all menus and their locations. But I can’t 
   create new menu or edit the existing. I have try to post url..wp-json/wp-api-
   menus/v2/menus but it doesn’t create new one. What I am doing wrong?
 *  Plugin Author [Fulvio Notarstefano](https://wordpress.org/support/users/nekojira/)
 * (@nekojira)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/children-hook/#post-6119418)
 * [@goharika](https://wordpress.org/support/users/goharika/), the plugin doesn’t
   create new menu items, you have to use WordPress default menus functions and 
   interface to do that: [https://codex.wordpress.org/WordPress_Menu_User_Guide](https://codex.wordpress.org/WordPress_Menu_User_Guide)
 *  Plugin Author [Fulvio Notarstefano](https://wordpress.org/support/users/nekojira/)
 * (@nekojira)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/children-hook/#post-6119419)
 * [@goharika](https://wordpress.org/support/users/goharika/), this plugin doesn’t
   create new menu items, you have to use WordPress default menus functions and 
   interface to do that: [https://codex.wordpress.org/WordPress_Menu_User_Guide](https://codex.wordpress.org/WordPress_Menu_User_Guide)
   once that is done, the menu and their elements will be available to the rest 
   api with this plugin
 *  [Goharika](https://wordpress.org/support/users/goharika/)
 * (@goharika)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/children-hook/#post-6119420)
 * yes I know, but I need to create new one from my application, so I need to post
 *  Plugin Author [Fulvio Notarstefano](https://wordpress.org/support/users/nekojira/)
 * (@nekojira)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/children-hook/#post-6119421)
 * sorry then, currently it’s in read mode only
 * [https://github.com/nekojira/wp-api-menus/blob/master/lib/wp-api-menus-v2.php#L47](https://github.com/nekojira/wp-api-menus/blob/master/lib/wp-api-menus-v2.php#L47)
 * to do other CRUD operations the plugin needs to be expanded further

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘children hook’ is closed to new replies.

 * ![](https://ps.w.org/wp-api-menus/assets/icon-256x256.png?rev=1070279)
 * [WP API Menus](https://wordpress.org/plugins/wp-api-menus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-api-menus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-api-menus/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-api-menus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-api-menus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-api-menus/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [json](https://wordpress.org/support/topic-tag/json/)

 * 7 replies
 * 3 participants
 * Last reply from: [Fulvio Notarstefano](https://wordpress.org/support/users/nekojira/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/children-hook/#post-6119421)
 * Status: resolved