Camen Design Forum


(Leave this as-is, it’s a trap!)

To delete this post you must be either the original author or a designated moderator.
The content of the post will be removed but the name and date will remain.

  • The post will be removed completely from the thread, rather than blanked
  • Only posts on the last page of the thread can be removed completely (so as to not break permalinks)

RE[6]: How to get latest posts


Yes. This only scans subfora and only one level down. It you have nested fora, probably a good idea with many fora, then you probably need to use
For me the above is very simple and works wonderful in my setup.

I've cleaned the code a bit this morning and put it in a function.

function latestFeed($n) {
	foreach (glob("forum/*/index.xml") as $filename) {
		$feeds[] = $filename;
// Get all feed entries
	$entries = array();
	foreach ($feeds as $feed) {
    	$xml = simplexml_load_file($feed);
    	$entries = array_merge($entries, $xml->xpath('/rss//item'));

// Sort feed entries by pubDate (descending)
	usort($entries, function ($x, $y) {
    	return strtotime($y->pubDate) - strtotime($x->pubDate);

	foreach (array_slice($entries,0,$n) as $entry){
		$entry->description=strip_tags(mb_substr($entry->description, 0, 100, 'UTF-8')) . '...';
return $latest;

I call the above with the following:

    require_once 'forum/joinfeeds.php';

to get the latest 5 posts.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn