- Cannot Use Object of Type WP_Error as Array: What the Fatal Error Means
- Why a WordPress Function Returns a WP_Error Instead of an Array
- What We Reproduced Behind the WP_Error as Array Fatal
- How to Find the Plugin or Theme Behind the Fatal
- How to Fix WP_Error as Array in Code You Control
- Decode the WP_Error Behind Your Fatal Error
- What to Do When WP_Error as Array Comes From Code You Did Not Write
- Frequently Asked Questions: WP_Error as Array Fatal Error
- How do I fix the Cannot use object of type WP_Error as array error in WordPress in 2026?
- Cannot use object of type WP_Error as array: PHP error vs WordPress error, which is it?
- Does isset or the null coalescing operator stop the WP_Error as array fatal on PHP 8.5 in 2026?
- Why does wp_remote_get return a WP_Error instead of a 404 or 500 status?
- is_wp_error vs wp_remote_retrieve_response_code in WordPress 7.1: which check does a safe handler need?
- When a plugin hits WP_Error as array after WP_HTTP_BLOCK_EXTERNAL is set in wp-config.php, what should I allow?
- Does switching PHP versions in AHosting cPanel remove the WP_Error as array fatal?
- How do I find which plugin throws WP_Error as array on an AHosting account without SSH?
- Is turning display_errors off a safe fix for a fatal like this in 2026?
- What is the WP_Error return problem, and how does the AHosting WP_Error Decoder help?
The WP_Error as array fatal means code indexed a WP_Error object like an array, after a WordPress function failed and returned the object instead of the result. Call is_wp_error() before you touch the result, then read the error message to find what really failed.
Cannot Use Object of Type WP_Error as Array: What the Fatal Error Means
Cannot use object of type WP_Error as array is a PHP fatal error, not a WordPress setting. Some code received a WP_Error object and then indexed it like an array, for example with $response['body']. PHP stops the request on the spot. We reproduced the WP_Error as array fatal on a clean WordPress 7.1.5 install running PHP 8.5.10. The visitor got HTTP 500 and the text “There has been a critical error on this website”, and the debug log held one line.
In the log, the line read PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /wp-content/mu-plugins/buggy.php:5, where the path was our test file. The cause is mechanical: the WP_Error class (wp-includes/class-wp-error.php, line 19) does not implement PHP’s ArrayAccess interface, which is the interface that lets an object answer square brackets. No ArrayAccess means no brackets.
That object only exists because something else failed first: a web request, a duplicate term, a missing taxonomy. So the fatal is the second failure. Fixing the first one is what matters, and most guides skip it.
Why a WordPress Function Returns a WP_Error Instead of an Array
Many WordPress functions return a union of types. The docblock above wp_remote_get() in http.php says @return array|WP_Error (the docblock is at line 184, the function at line 187). The vertical bar is the notation that PHPDoc uses for multiple types. So the caller gets an array on success and a WP_Error object on failure, and nothing in the language forces the caller to look. Rust’s Result type makes that look mandatory, while PHP leaves it to you.
The test WordPress gives you is is_wp_error(), a single instanceof check (load.php, line 1804). The diagram shows both paths.
Two details cause most of the confusion. First, an HTTP error status is not a WP_Error: in our lab api.wordpress.org answered a bad path with a 404, and wp_remote_get() returned a normal array. Second, get_term() returned null for a missing ID, a third outcome that fails in a different way.
What We Reproduced Behind the WP_Error as Array Fatal
We ran each call below on one local lab install (WordPress 7.1.5, PHP 8.5.10, a SQLite database, not an AHosting server) and recorded what came back. The first three network rows show why a host sees this error so often: DNS, connection and certificate failures all arrive as a WP_Error, not as a status code.
| Call we made | What came back | Detail |
|---|---|---|
| wp_remote_get, host that does not exist | WP_Error: http_request_failed | cURL error 6: Could not resolve host |
| wp_remote_get, port with no listener | WP_Error: http_request_failed | cURL error 7: Failed to connect |
| wp_remote_get, expired certificate | WP_Error: http_request_failed | cURL error 60: certificate has expired |
| wp_remote_get, WP_HTTP_BLOCK_EXTERNAL true | WP_Error: http_request_not_executed | User has blocked requests through HTTP |
| wp_remote_get, bad path on api.wordpress.org | Normal array, status 404 | Not a WP_Error |
| wp_insert_term, same name twice | WP_Error: term_exists | Error data held the existing term ID |
| get_term, ID that does not exist | null | Neither array nor WP_Error |
| get_term, unregistered taxonomy | WP_Error: invalid_taxonomy | Taxonomy name not registered |
The blocked row matters on shared hosting: the http_request_not_executed code means WordPress itself refused to send the request, because the block constant is set in wp-config.php.
How to Find the Plugin or Theme Behind the Fatal
Work from the log, not from guesses. The fatal line ends with a file path and a line number, and that path names the code that indexed the object.
- Turn on logging without showing errors to visitors: set
WP_DEBUGandWP_DEBUG_LOGto true andWP_DEBUG_DISPLAYto false in wp-config.php. In our lab the log landed in wp-content/debug.log. - Reload the failing page once, then read the newest
Cannot use object of type WP_Error as arrayline. A path such as/wp-content/plugins/example-plugin/includes/api.php:88points at the plugin folderexample-plugin. - Restore the site by renaming that plugin folder in cPanel File Manager, which deactivates the plugin. Our guide to a plugin that could not be activated and our white screen walkthrough cover the same recovery.
Delete or protect the log when you are done. A debug file inside the web root can be fetched by anyone who guesses the path, as we explain in our guide to logs in a public file.
How to Fix WP_Error as Array in Code You Control
Check First, Then Index
Test the result with is_wp_error() before any bracket touches it. A safe handler reads $r = wp_remote_get( $url );, then if ( is_wp_error( $r ) ) { error_log( $r->get_error_message() ); return; }, and only then $body = wp_remote_retrieve_body( $r );. The helper wp_remote_retrieve_body() is itself guarded: it returns an empty string when it gets a WP_Error (http.php, line 316).
Why isset() Does Not Stop the WP_Error as Array Fatal
Developers often reach for a guard that works on arrays. On a WP_Error, none of them work. We ran each one in the lab against a failed request.
| Pattern on a failed request | Result on PHP 8.5.10 | Safe? |
|---|---|---|
| $r[‘body’] | Fatal Error: Cannot use object of type WP_Error as array | No |
| isset( $r[‘body’] ) | Same fatal Error | No |
| empty( $r[‘body’] ) | Same fatal Error | No |
| $r[‘body’] ?? ” | Same fatal Error | No |
| wp_remote_retrieve_body( $r ) | Returns an empty string, no error | Safe, but hides the failure |
| is_wp_error( $r ), then get_error_message() | Returns the cURL message | Yes |
The helper functions return an empty string or an empty code for a WP_Error (http.php, lines 282 to 288), so they stop the crash and also hide the cause. Log the message first.
Decode the WP_Error Behind Your Fatal Error
The error code in your log is the fastest clue. Pick it below to see the usual cause and the next check. The entries come from the lab results above.
What to Do When WP_Error as Array Comes From Code You Did Not Write
You cannot patch a plugin that updates itself, so decide what the WP_Error is telling you. If the message is a cURL error 6, 7 or 60 or a blocked request, the plugin is only the messenger: its web request failed at the server, and the plugin crashed on the answer. Our guide to a failed secure connection to WordPress.org shows how those server-side causes look.
The fix above is code you can own, while the failed request behind it is where a host helps. On shared web hosting, ask support to check DNS and outbound connections from your account. If you need to control the network yourself, a VPS plan gives you that access. Either way, report the plugin bug with the exact fatal line and the WP_Error message from your log.
Frequently Asked Questions: WP_Error as Array Fatal Error
How do I fix the Cannot use object of type WP_Error as array error in WordPress in 2026?
Specifically, find the file and line in the log, then make that code call is_wp_error() on the result before it indexes it. If the code belongs to a plugin, update or replace the plugin, and read the WP_Error message to learn what failed first.
Cannot use object of type WP_Error as array: PHP error vs WordPress error, which is it?
In practice it is both. PHP throws the fatal because the WP_Error class does not implement ArrayAccess, and WordPress supplies the object because a function failed. The PHP error is the symptom, and the WordPress failure behind it is the cause.
Does isset or the null coalescing operator stop the WP_Error as array fatal on PHP 8.5 in 2026?
Specifically, no. In our lab on PHP 8.5.10, isset, empty and the null coalescing operator all threw the same Error when the value was a WP_Error. For example, a check like isset on a body key still fails, so call is_wp_error first.
Why does wp_remote_get return a WP_Error instead of a 404 or 500 status?
Specifically, a WP_Error means the request never produced an HTTP reply, for example a failed DNS lookup or a refused connection. A 404 or 500 is a reply, so wp_remote_get returns a normal array and you read the status from it.
is_wp_error vs wp_remote_retrieve_response_code in WordPress 7.1: which check does a safe handler need?
In other words, they test different failures. The function is_wp_error asks whether the call failed before any reply, while wp_remote_retrieve_response_code reads the status of a reply that arrived. A safe handler needs both, in that order.
When a plugin hits WP_Error as array after WP_HTTP_BLOCK_EXTERNAL is set in wp-config.php, what should I allow?
Specifically, add the hostnames the plugin needs to the WP_ACCESSIBLE_HOSTS constant, or remove the block constant. Core blocks every host except your own site and localhost when WP_HTTP_BLOCK_EXTERNAL is true, and the error code you see is http_request_not_executed.
Does switching PHP versions in AHosting cPanel remove the WP_Error as array fatal?
In practice, no. The cause is the code treating an object as an array, and the PHP manual lists ArrayAccess for PHP 5, 7 and 8 alike, so the object behaves the same. We reproduced it on PHP 8.5.10, and a version switch only helps if a plugin update changed the code.
How do I find which plugin throws WP_Error as array on an AHosting account without SSH?
Specifically, set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false in wp-config.php using cPanel File Manager, reload the failing page, and open wp-content/debug.log. The first path in the fatal line names the plugin or theme folder.
Is turning display_errors off a safe fix for a fatal like this in 2026?
Specifically, no. In our lab, with WP_DEBUG_DISPLAY set to false, the visitor still got HTTP 500 and the critical error page, because the fatal stops the request either way. Hiding the message hides your clue, and the broken page remains.
What is the WP_Error return problem, and how does the AHosting WP_Error Decoder help?
In other words, many functions return an array or a WP_Error, and code that assumes only the array fails on the first error. The AHosting WP_Error Decoder in this post maps the code in your log to its usual cause and to the next check.


















