I am trying to add a new menu item to an already existing nav menu in my theme, I am using some part of this answer How to Hard Code Custom menu items
I am directly using this code in my plugin
wp_update_nav_menu_item(2, 0, array(
'menu-item-title' => __('Home'),
'menu-item-classes' => 'home',
'menu-item-url' => home_url( '/' ),
'menu-item-status' => 'publish'));
But it gives me following error
Your PHP code changes were rolled back due to an error on line 357 of file C:\xampp\htdocs\wordpress\wp-includes\link-template.php. Please fix and try saving again
Call to a member function get_page_permastruct() on null