Last modified by Safiye A. Duman - 3 years ago
Less than a minute read

How to get error message when using wp_remote_post and wp_remote_get

When using WordPress HTTP API, if the connection fails you could use the below code to display the error message.

Both wp_remote_post and wp_remote_get return WP_Error object if there is an error.  You could use the get_error_message function of WP_Error class to receive the error and show it.

Was this information helpful?