Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
When using WordPress HTTP API, if the connection fails you could use the below code to display the error message.
$response = wp_remote_post($url);
if (is_wp_error($response)) {
$error = $response->get_error_message();
echo $error;
} else {
$content = wp_remote_retrieve_body($response);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.