function is_wp_error($thing) {}

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.


  • mixed $thing: Check if unknown variable is WordPress Error object.

Return values

returns:True, if WP_Error. False, if not WP_Error.

Source code

function is_wp_error($thing) {

	if ( is_object($thing) && is_a($thing, 'WP_Error') )

		return true;

	return false;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: