Fix: array_map(): Expected parameter 2 to be an array, null given

image 1

If you’re a WordPress user or developer, you might have encountered an annoying array_map(): Expected parameter 2 to be an array, null given error at some point. This error can bring your website’s functionality to a halt and lead to confusion if you’re not familiar with its root cause and solution.

Additionally, some users who use the RankMath SEO plugin may also face an issue with the plugin’s redirection feature. In this article, we’ll delve into these two problems and provide step-by-step solutions to get your WordPress site back on track.

Understanding the array_map() Error

What is the array_map() Function?

The array_map() function in PHP is used to apply a given callback function to all items of an array. This can be incredibly useful for manipulating arrays efficiently.

The Error Message Explained

The error message “array_map(): Expected parameter 2 to be an array, null given” indicates that the function is expecting an array as its second parameter, but it’s receiving a null value instead. This commonly occurs when you’re attempting to use array_map() on an array that’s missing or has become null due to an earlier operation.

Identifying the Cause

To troubleshoot this error, you’ll need to locate the code that triggers it. If it is a code then Check the line number mentioned in the error message to narrow down the source. Inspect the preceding code to find out where the array might not have been properly initialized or where an operation unexpectedly resulted in a null value.

If you encounter issues on WordPress, you can temporarily disable the plugin in which you are getting this error, and then again reactivate that plugin. Do remember to clear the cache when you this to see live updates.

Resolving RankMath Redirection Issues

RankMath SEO Plugin and Redirection

The RankMath SEO plugin for WordPress offers various features to enhance your website’s search engine optimization. One of its features is the redirection module, which allows you to manage and set up redirects for your website’s URLs.

Some users have reported issues with the RankMath redirection module. After entering redirect URLs, they might face problems where the redirects don’t add to the list.

Solution: Deactivate and Reactivate Redirection

If you’re encountering issues with the RankMath redirection module, a simple yet effective solution is to deactivate and then reactivate the redirection feature from your WordPress dashboard. Follow these steps:

  1. Log in to your WordPress dashboard.
  2. Navigate to the “RankMath” section in the left sidebar.
  3. Click on “Dashboard.”
  4. Scroll down to find the “Redirections” option and disable it.
  5. Clear the cache of the whole site.
  6. Save your changes and then enable the redirection feature again.


Dealing with errors and plugin issues is an inevitable part of managing a WordPress website. By understanding the array_map() error and knowing how to tackle RankMath redirection problems, you’ll be better equipped to maintain a smooth and functional website. Remember to double-check your code for array handling and follow the steps to resolve RankMath redirection hiccups.

Leave a Comment