is_wp_error

Check whether variable is a WordPress Error.

Description

is_wp_error( (mixed) $thing ); 

Returns true if $thing is an object of the WP_Error class.

Parameters (1)

0. $thing (mixed)
Check if unknown variable is a WP_Error object.

Usage

  1. if ( !function_exists( 'is_wp_error' ) ) { 
  2. require_once ABSPATH . WPINC . '/load.php'; 
  3.  
  4. // Check if unknown variable is a WP_Error object. 
  5. $thing = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_wp_error($thing); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/load.php  
  1. function is_wp_error( $thing ) { 
  2. return ( $thing instanceof WP_Error );