Codex

Function Reference/is wp error

Contents

Description

Check whether variable is a WordPress Error.

Looks at the object and if a WP_Error class. Does not check to see if the parent is also WP_Error, so can't inherit WP_Error and still use this function.

Usage

<?php is_wp_error$thing ); ?>

Parameters

$thing
(mixed) (required) Check if unknown variable is WordPress Error object.
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/class-wp-error.php.

Related