
I made a custom WordPress template for Printhouse Corporation. Printhouse has a blog with a seperate WordPress install (and subdomain). It was required to show an excerpt of the latest blog post from the seperate blog, in the footer of the official Printhouse website.
The way I thought about it, was to use the blog’s RSS feed to show the latest blog post. I found a bit of code from WpRecipes website. This only list a few titles of the latest blog posts. In this post I explain how to display the latest blog post from a different website, using SimplePie and the RSS feed in your WordPress website.
1. Install SimplePie Core Plugin
Most importantly use the SimplePie to make this work. As it says on the SimplePie website:
SimplePie is a very fast and easy-to-use class, written in PHP, that puts the ‘simple’ back into ‘really simple syndication’.
Thus, first install theĀ SimplePie Core WordPress plugin to load the core SimplePie API library.
2. Call RSS Feed
The code snippet start off by placing the following where you would like the latest post to show, eg. sidebar or footer. This is to call the RSS feed that is going to be used.
<?php
$feed = new SimplePie('http://www.exampledomain.com/feed/');
?>
3. Code snippet for the post excerpt
Then add the rest of the code to create the title and an excerpt of the latest blog post of the RSS feed.
<h3><a href="http://www.exampledomain.com">Example Heading</h3>
<?php $item = $feed->get_item() ?>
<h4><a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php echo $item->get_title(); ?></a></h4>
<p><?php print $item->get_description(); ?></p>
The image on the left is an example of the result.
First a static heading. It depends on the website structure and where this go, which heading tags to use. Followed by the latest blog excerpt with the title as a link to the blog post.


I know this post is quite old, but would appreciate your help – How do I shorten the RSS description that’s output from being too long? Some of them (as you may know) are not configured very well to output an excerpt. Thanks!
It can be done with SimplePie – here is the reference: http://simplepie.org/wiki/tutorial/shorten_titles_and_descriptions
Basically add the following
shortenfunction (you can also grab it from the page at that link) to your function.php:function shorten($string, $length) {
$suffix = '…';
$short_desc = trim(str_replace(array("\r","\n", "\t"), ' ', strip_tags($string)));
$desc = trim(substr($short_desc, 0, $length));
$lastchar = substr($desc, -1, 1);
if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?') $suffix='';
$desc .= $suffix;
return $desc;
}
Then replace:
get_description(); ?>withget_description(), 150); ?>The 150 is for the amount of characters, that can be changed accordingly.
Hope that helps!