Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Call function with ID of wanted menu, for example 'main-menu'
- function cleanmenu( $menuID ) {
- $menu = array();
- foreach ( wp_get_nav_menu_items( $menuID ) as $link ):
- $menu[ $linkki->ID ] = array(
- 'title' => $link->title,
- 'url' => $link->url,
- 'is_children' => false,
- 'has_children' => false,
- 'childrens' => array()
- );
- if ( $link->menu_item_parent !== '0' ): // Launch if menu-item has parent item
- $menu[ $link->ID ][ 'is_children' ] = true;
- $menu[ $link->menu_item_parent ][ 'has_children' ] = true;
- array_push( $menu[ $link->menu_item_parent ]['childrens'], $link->ID );
- endif;
- endforeach;
- return $menu;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement