Search code examples
phpwordpress-rest-api

get category and sub category list of top menu in wordpress


I am very new in WordPress and I have to create an API to get a list of category and it's subcategory of top navigation in WordPress.


Solution

  • wp_get_nav_menu_items( string $menu )
    
    $menu = 
    (string) (Required) Menu name, ID, or slug.
    

    you can use this function to print out all the menu item with submenu