When I use file_get_contents with get_bloginfo it seems to work fine when I am working on the site locally and on the staging server. However when the site goes live it stops working and gives me this error "Warning: file_get_contents(https://www.websiteurl.com/wp-content/themes/theme-name/assets/svg/logo.svg): failed to open stream: Connection timed out in /home/websiteurl/public_html/wp-content/themes/theme-name/header.php on line 38.
When I open this link https://www.websiteurl.com/wp-content/themes/theme-name/assets/svg/logo.svg the svg loads just fine. So why does it give me this error?
Here is the current code:
<?php
$svgLogo = file_get_contents(get_bloginfo('template_url').'/assets/svg/logo.svg');
?>
<?php echo $svgLogo; ?>
When I change it to this the error goes away:
<?php
$svgLogo = file_get_contents('https://www.websiteurl.com/wp-content/themes/website-theme/assets/svg/logo.svg');
?>
<?php echo $svgLogo; ?>