Back to Community

Fixing WordPress Importer Menu Issues: PHP7 Errors, Missing Items, and Duplicates

19 threads Sep 16, 2025 PluginWordpress importer

Content

The WordPress Importer plugin is a vital tool for migrating content, but users frequently encounter problems with navigation menus. Based on community reports, the most common issues involve menus failing to import, menu items being duplicated, or custom menu meta data not being brought over. This guide explains why these problems occur and provides the most effective solutions.

Common WordPress Importer Menu Problems

Users typically face one of three main issues:

  1. Menus fail to import entirely, often with PHP notices about "Array to string conversion" or "Undefined variable" errors.
  2. Menu items are duplicated upon re-import.
  3. Custom fields and meta data for menu items (e.g., from plugins like Nav Menu Roles) are present in the XML file but are not imported.

Why These Menu Issues Happen

The root causes are varied:

  • PHP 7+ Incompatibility: A specific code syntax issue on line 798 (or 884 in some versions) of the wordpress-importer.php file causes failures. The old method of variable variable assignment ($$meta['key']) is not fully compatible with newer PHP versions.
  • Missing Hooks for Custom Meta: The importer's process_menu_item() function does not natively handle the import of custom post meta for navigation menu items, which is required by many menu-related plugins.
  • No Deduplication Check: The importer does not always check for existing identical menu items before creating new ones, leading to duplicates if an import is run multiple times.

Solutions and Workarounds

Solution 1: Fix the PHP 7+ Compatibility Error

This is the most common fix for menus that fail to import with PHP notices.

  1. Access your website's files via FTP or your hosting file manager.
  2. Navigate to /wp-content/plugins/wordpress-importer/.
  3. Edit the file wordpress-importer.php.
  4. Find line 798 (or approximately line 884). The original code will look like this:
    $$meta['key'] = $meta['value'];
  5. Change it to the following syntax, which is compatible with PHP 5.6+ and PHP 7+:
    ${$meta['key']} = $meta['value'];
  6. Save the file and re-run the import.

Note: This fix has been committed to the plugin's GitHub repository and may be included in a future update. Always back up your site before editing plugin files.

Solution 2: Manually Import Custom Menu Item Meta Data

For users who need custom menu fields (e.g., for mega menus or visibility rules) to be imported, a code modification is required. The community has long requested a hook for this, but a manual patch can be applied.

Within the same process_menu_item() function in wordpress-importer.php, locate the section where post meta is processed. You may need to ensure the function loops through all available custom fields in the import file and adds them correctly. This solution requires comfort with PHP and should be done cautiously.

Solution 3: Preventing and Cleaning Up Duplicate Menus

If your import has created duplicate menu items, follow these steps:

  1. Clean Slate: The most reliable method is to start over. Before a new import, delete all previously imported content (posts, pages) and empty the trash. Then, manually delete the old navigation menus from Appearance > Menus.
  2. Use a Cleanup Plugin: Tools like the WP Reset plugin can be used to quickly clean a development or staging site of all content and menus, allowing for a fresh import attempt.
  3. Avoid Re-running Imports: If an import is interrupted, do not simply run it again. Always clear previous import data first to prevent duplication.

Conclusion

Menu import issues with the WordPress Importer are typically solvable. The PHP 7 compatibility fix resolves the problem for most users. For more advanced needs involving custom menu data, manual code patches may be necessary until the plugin adds official support. Always remember to import on a staging site first and maintain full backups to avoid complicated cleanup operations on your live website.

Related Support Threads Support