Blog

Fix WordPress Import Navigation Issues in PHP7

macbook pro beside white ceramic mug on brown wooden table

There are many reasons why the WordPress Import plugin or custom plugins that are based on the default WordPress Import would fail. Sometimes there are issues with the server, such as insufficient memory or timeout limits. In other cases, the import file itself is too large. In this article, we’ll focus on the WordPress Import not importing properly Navigation menu items. This usually happens when you’re using PHP7 on your server. The entire WordPress Import process seems to be completed properly, but there are no navigation menus imported.

Fix WordPress Import issues with the Main Navigation

If you have PHP7 installed on your server, the WordPress Importer plugin would probably fail to import menu/navigation items. Although this works flawlessly on earlier versions of PHP (5.4+), people who made the migration to PHP7 encountered this error. It is a really easy fix, so let’s get started.

When you try to import menu items with the plugin on PHP7, you’ll get the following error:
Notice: Array to string conversion in /wp-content/plugins/wordpress-importer/wordpress-importer.php on line 798

Custom WordPress Import plugin? Not a Problem!

Note that if you are using a 3rd party plugin, that many premium themes come with, you can still change the import file. Try to find the WordPress Import script or file, and make sure to edit it. It can be embedded within plugins such as ‘One Click Importer’ that are often bundled within premium themes, as mentioned above.

Modifying the Code

To make this error disappear and fix the issue, open the wodpress-importer.php file in your favorite text editor, navigate to line 798, and apply the following change:

Change

$$meta[‘key’] = $meta[‘value’];

To

${$meta[‘key’]} = $meta[‘value’];

Once you save the file, reload WordPress and everything should work fine.

Note – For further reading, you can check out the original ticket opened in the Make WordPress Core



Scroll to top