How To Fix Cannot Use Object As Array


Symptoms

Either a blank website page or a fatal error as shown in the example below:

Cannot use object of type WP_Error as array

Cause

Invalid use of the variable containing object that does not extends ArrayObject class.

Requirements

In order to fix this fatal error, you should have good knowledge in PHP to debug the source code.

Read Me First

This error can be automatically fixed with CodePinch. Download CodePinch on your website and within hours we will be able to provide you with solution.

Resolution

The example below shows how to fix “cannot use object as array” fatal error. This solution ensures that your website get executed.

@@ -11,9 +11,9 @@
- if (!empty($response['body'])) {
+ if ( is_array($response) && !empty($response['body']) {

Fix WordPress PHP errors instantly with CodePinch!

Get Started
Thank You! Message Submitted Successfully!