wp_remote_get returns an error for valid URL

I currently have the following snippet of php to fetch some HTML and render it in my theme(squash theme). <?php $response = wp_remote_get( ‘http://www.toucan-it.co.uk/wp-content/themes/squash/index5.html’ ); print $response [‘body’]; ?> The file I’m trying to request is available at the following URL. http://www.toucan-it.co.uk/wp-content/themes/squash/index5.html Problem The problem is when trying to retrieve ‘index5.html’ via the web browser … Read more

wp_remote_get – cURL error 28 – only on same domain

On my website I use wp_remote_get to fetch data from mydomain.com/wp-json/wp/v2/pages/75 When I run it on my localhost it works fine, but after sending to production server (mydomain.com) suddenly I’m getting error: ‘cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received’ + VPS starts acting crazy (100% cpu usage and memory). … Read more

How to consume and display external data in WordPress from another website

I am trying to access data from another website to display on a WordPress Website I am developing. So far I have the following: <?php /* Template Name: Testing remote data */ get_header(); <div class=”main”> <div class=”col-sm-12″> <header> <h2>Testing remote data</h2> </header> </div> <div class=”container”> <div id=”content” role=”main”> <div class=”col-sm-12″> <?php $url=”http://www.bbc.co.uk/news/”;// this url is … Read more

How to wp_upload_bits() to a sub-folder?

I am using wp_upload_bits() to copy an obtained remote image… $upload = wp_upload_bits($file, ”, wp_remote_retrieve_body( $get )); Image source example: https://logo.clearbit.com/starcomww.com The following code seems to obtain the image well enough: $get = wp_remote_get( $image_url ); $type = wp_remote_retrieve_header( $get, ‘content-type’ ); $file (name of file) is set at eg. starcom-mediavest-group.png So I see how … Read more