Skip to content

Instantly share code, notes, and snippets.

@Naktibalda
Forked from anonymous/gist:4086131
Created November 16, 2012 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Naktibalda/4086202 to your computer and use it in GitHub Desktop.
Save Naktibalda/4086202 to your computer and use it in GitHub Desktop.
<?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