Custom RSS causing timeout for website

As @TomJNowell mentioned it’s weird to use get_headers() for this. It would be better to remove the $img variable entirely and just use strlen() in your enclosure to get the length of the string in bytes: <enclosure url=”<?php if ( has_post_thumbnail( $post->ID ) ) { the_post_thumbnail_url(); } ?>” length=”<?php if ( $image ) { echo … Read more

Cache a number of responses from external json feeds?

$body = get_transient( ‘my_api_response_value’ ); if ( false === $body ) { $url=”” . $ticker . ”; $response = wp_remote_get($url); if (200 !== wp_remote_retrieve_response_code($response)) { return; } $body = wp_remote_retrieve_body($response); set_transient( ‘my_api_response_value’, $body, 5*MINUTE_IN_SECONDS ); } $formatted_json = json_decode($body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); We submit a request at the beginning because the transient doesn’t … Read more

How do I get an RSS feed to work

You seem to have an invalid feed. There’s a <center></center> tag at the beginning opening the file instead of <?xml version=”1.0″ encoding=”UTF-8″?>. You need to fix that. I don’t know where that comes from, probably from some post being not well formatted, or from some plugin or your theme. Try disabling all your plugins and … Read more