You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
// Replace with the actual RSS feed URL
$feed_url = "https://example.com/blog/feed/rss";
// Fetch the feed content
$feed_content = file_get_contents($feed_url);
// Check if content was fetched successfully
if ($feed_content) {
// Parse the XML content
$xml = simplexml_load_string($feed_content);
// Get the first item (latest post)
$latest_post = $xml->channel->item[0];
// Extract title and link
$title = $latest_post->title;
$link = $latest_post->link;
$text = $latest_post->description;
$cat = $latest_post->category;
$date_string = $latest_post->pubDate;
$date = new DateTime($date_string);
// Display the information
echo $title.'<br />';
echo $text." <a href='$link'>[Read More]</a><br />";
echo "Posted $date in $cat";
} else {
echo "Error: Could not retrieve blog contents.";
}
?>
If you need to display more than one post, you can loop the code and change item[0] to increment.
My HTMLy blog is inside my root/blog.
I wish to get the my blog's LATEST POSTS INDEX into my root domain's page. How to integrate please?
Is something like same as wordpress latest posts widget..
The text was updated successfully, but these errors were encountered: