I know this has been posted before, but none of the answers are working for me. I am missing something and would appreciate any help.
I have WordPress installed in a folder called “news” and it is working. I would like to display recent blog posts via RSS on a different page (the page is not generated by WordPress).
I am getting the following error:
Fatal error: Call to a member function getElementsByTagName() on a
non-object
Here is the code I’m using:
$xml=("http://www.williamsargent.info/avadasoftware/news?feed=rss2");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
You can use following, this is more readable;