Skip to:

Re: External Blogs



Here’s the code I use in the current version of my site – Kunal17 asked about it:

// Include the SimplePie library
require_once '';
require_once 'shorten.php';

// Because we're using multiple feeds, let's just set the headers here.
header('Content-type:text/html; charset=utf-8');

// These are the feeds we want to use
@mysql_select_db($db_name) or die( "Unable to select database");

$query = "SELECT id, email, firstname, surname, rssfeed FROM members WHERE rssfeed != ''";
$result = mysql_query($query);

$feeds = array();
$id_array = array();
$first = array();
$user = array();

$userinfo = array();

while ($cur_feed = mysql_fetch_assoc($result))
$feeds[] = $cur_feed['rssfeed'];
$userinfo[$cur_feed['rssfeed']] = $cur_feed;

// This array will hold the items we'll be grabbing.
$first_items = array();

// Let's go through the array, feed by feed, and store the items we want.
$ix = 0;

foreach ($feeds as $url)
$user_id = $id_array[$ix];
$firstname = $first[$ix];
$surname = $sur[$ix];
$email = $user[$ix];

// Use the long syntax
$feed = new SimplePie();

// How many items per feed should we try to grab?
$items_per_feed = 1;

// As long as we're not trying to grab more items than the feed has, go through them one by one and add them to the array.
for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++)
$first_items[] = $feed->get_item($x);

// We're done with this feed, so let's release some memory.

// We need to sort the items by date with a user-defined sorting function. Since usort() won't accept "SimplePie::sort_items", we need to wrap it in a new function.
function sort_items($a, $b)
return SimplePie::sort_items($a, $b);

// Now we can sort $first_items with our custom sorting function.
usort($first_items, "sort_items");

foreach($first_items as $item)
$feed = $item->get_feed();
$info = $userinfo[$item->feed->feed_url];

if($counter >= 7)

if ($img_size = @getimagesize('members/img/avatars/'.$info['id'].'.jpg'))
$avatar_field = '<img src="members/img/avatars/'.$info['id'].'.jpg" alt="" />';
$avatar_field = '<img src="members/img/avatars/nopicture.png" alt="" />';

$picture = '<div id="feedpicture"><a href="members/member.php?id='.$info['id'].'" title="'.$info['firstname'].'\'s Member Page">'.$avatar_field.'</a></div>';

// Begin the (X)HTML page.

<h3><?php echo $picture; ?><a href="<?php echo $item->get_permalink(); ?>" target="_blank"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></h3>

<!-- get_content() prefers full content over summaries -->
<? echo trim(substr((str_replace("\n", ' ', str_replace("\r", ' ', strip_tags($item->get_description())))),0,300)); ?>
... <i>more</i></a><br />

<p class="info"><a href="members/member.php?id=<?php echo $info['id']; ?>" title="<?php echo $info['firstname'].'\'s Member Page'; ?>"><?php echo $info['firstname'].' '.$info['surname']; ?></a> | <a href="<?php echo $feed->get_permalink(); ?>" target="_blank"><?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('M j, Y | g:i a'); ?></p>
<br />


It shows the latest blog posts from members on a page, if they have an RSS feed in the database. It uses SimplePie. The code above is customized from regular SimplePie feed code. Member management in my current site is based on PunBB, not WordPress.

I’d have no clue how to modify this code for Buddypress. Can’t figure out member management in Buddypress for starters, with x-profile vs wpmu and similar data stored in different places. It all looks kinda messy and inconsistent to me.

Doubtful you should take this as starting point. I’ll wait for the integrated solution.

Skip to toolbar