setOptions(array("timeout"=>1)); $response = $client->send(); $response_data = json_decode($response->getBody()); if (!$response->isClientError() && $response_data) { foreach ($response_data as $menu_item) { $item_url = $menu_item->url; if (strtolower($menu_item->title) == 'login') { $item_url = "/login"; } $item_title = $menu_item->title; if (strtolower($menu_item->title) == 'collections') { $item_title = "Project"; $item_url = $wordpress_site; } $item = [ "id" => $menu_item->ID, "title" => $item_title, "url" => $item_url ]; if (!array_key_exists($menu_item->menu_item_parent, $items)) { $items[$menu_item->menu_item_parent] = new ArrayObject(); } $items[$menu_item->menu_item_parent][$menu_item->ID] =$item; } } } //print_r($items); function render_menu($items, $level_id) { echo '