-
-
Save Naktibalda/4086202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_menu_items( $menu_name ) { | |
if( !$menu_name ) | |
return false; | |
if( ( $locations = get_nav_menu_locations() ) && isset( $locations[$menu_name] ) ) { | |
$menu = wp_get_nav_menu_object( $locations[$menu_name] ); | |
$menu_items = wp_get_nav_menu_items( $menu->term_id ) ; | |
$output = array(); | |
foreach ( (array) $menu_items as $key => $menu_item ) { | |
$output []= array( | |
'id' => $menu_item->object_id, | |
'title' => $menu_item->title, | |
'url' => $menu_item->url | |
) | |
} | |
return $output; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment