I have a website homepage that is static. There is a separate blog hosted on Wordpress on the same domain (at /blog). Six years ago, I asked a friend for help with displaying two recent posts from the blog on the homepage, and he did that by:
Changing the homepage from index.html to .php
included the following code in index.php
function blog() { $url = 'MysiteURL.com/blog/feed/'; $xmlinfo = simplexml_load_file($url); if($xmlinfo) { $temp=$xmlinfo->channel->item; $i=0; foreach ($temp as $key) { if($i<2) { echo '<div class="span5">'; $a=$key->title; echo '<div class="title"><a href ='.$key->link.'><h4>'.$a.'</h4></a></div>'; $pieces = explode("[", $key->description); echo '<div class="description">'.$pieces[0].'<a href ='.$key->link.'>... Read More</a></div>'; echo '</div>'; echo '<div class="span1"> </div>'; $i=$i+1; } } } } blog(); ?> ```
It used to work just fine until last year, when I got an SSL certificate, and moved my hosting from Godaddy legacy to new 'Starter Linux Hosting with cPanel'. And now the code is just not working. Other changes since last year or till the time the code was working and displaying posts:
- I have upgraded PHP to 7.4 (the latest version that Godaddy currently offers)
- I have upgraded Wordpress to latest version
I tested the code in https://sandbox.onlinephpfunctions.com/, and it showed me the following error:
<b>Warning</b>: simplexml_load_file() has been disabled for security reasons in <b>[...][...]</b> on line <b>477</b><br />
But if I view the 'page source', there is no sign of any output from the code. It is just blank. Could anyone please help me understand what is it that going wrong with PHP code execution? Thanks a lot in advance!