WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is wp error

Description

Checks whether the passed variable is a WordPress Error.

Looks at the variable and determines if it is both a PHP object and one populated by the WP_Error class.

Usage

<?php is_wp_error$thing ); ?>

Parameters

$thing
(mixed) (required) Any existing variable of a known or unknown type.
Default: None

Return Values

(boolean) 
True, if WP_Error. False, if not WP_Error.

Examples

if ( is_wp_error( $result ) ) {
   $error_string = $result->get_error_message();
   echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
}

Notes

Change Log

Since: 2.1.0

Source File

is_wp_error() is located in wp-includes/load.php.

Related

  • see WP_Error for more information on how to use the WP_Error class.