How to add submenu items programmatically in WordPress?
Appending an item to the existing menu can be done using the wp_nav_menu_objects hook. The submenu can be created using the current menu structure. In the submenu code snippet, we need to add the specific ID to become the child of the specific menu.