Title: PHPBB3 recent comments/posts in  the sidebar
Last modified: August 18, 2016

---

# PHPBB3 recent comments/posts in the sidebar

 *  [adrisilversun](https://wordpress.org/support/users/adrisilversun/)
 * (@adrisilversun)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/)
 * Hello all.
 * I need some help with my blog and my forum. I want to show the last 5 commented
   posts of my phpbb3 forum in my wordpress sidebar.
 * I have no idea about coding or php. How can I do it?
 * Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605685)
 * i have no idea too, but i’m guessing it would be quite hard to do. You may want
   t look at phpbb3 portal, if this doesn’t work.
 *  [polle001](https://wordpress.org/support/users/polle001/)
 * (@polle001)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605759)
 * Hi, I am looking for this as well, the last 10 topics or replies of a phpbb3 
   forum, any help is really apreciated.
 * Thanks.
 *  [Mattias Tengblad](https://wordpress.org/support/users/damst/)
 * (@damst)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605824)
 * Any news on this?
 *  [cogo](https://wordpress.org/support/users/cogo/)
 * (@cogo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605827)
 * There’s a no longer supported plugin by Brandon Alexander that I did some modifications
   to so that it works in phphBB3.
 * Create a folder named wp-phpbb-files in your plugins and put this in a file named
   wp-phpbb.php:
 *     ```
       <?php
       /*
       Plugin Name: WP-phpBB
       Plugin URI: http://yoda.gatewayy.net/
       Description: This plugin gives you the recent posts in your phpBB
       Version: .9
       Author: Brandon Alexander
       Author URI: http://yoda.gatewayy.net/
       */
   
       function show_posts($limit = 5)
       {
       global $wpdb;
       //Put your phpBB and wordpress database info here:
       $WPDB = ""; //WP db name
       $PHPBBDB = ""; //phpBB db name
       $USERS_TABLE = "phpbb_users"; //phpbb user table
       $TOPICS_TABLE = "phpbb_topics"; //phpbb topics table
       $POSTS_TABLE = "phpbb_posts"; //phpbb posts table
       $SITEURL = ""; //Forum URL with trailing /
       	//Do not edit beyond this point
       	$lastfpost = 0;
       	$top5=array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
       	$wpdb->select($PHPBBDB);
       	$test = 0;
       	$results = $wpdb->get_results("SELECT * FROM $POSTS_TABLE ORDER BY post_time DESC");
   
       	if ($results)
       	{
       		foreach ($results as $post)
       		{
       			$user = $wpdb->get_row("SELECT * FROM $USERS_TABLE WHERE user_id = $post->poster_id");
       			$forum = $wpdb->get_row("SELECT * FROM $TOPICS_TABLE WHERE forum_id = $post->forum_id");
       			$topic = $wpdb->get_row("SELECT * FROM $TOPICS_TABLE WHERE topic_id = $post->topic_id");
       			$test = 0;
       			for($i=0;$i<=$limit;$i++){
       			if($topic->topic_id==$top5[$i]){ $test=1; }
       			}
       			if($user && $topic && $test==0)
       			{
       				$top5[$lastfpost]=$topic->topic_id;
       				$lastfpost += 1;
       				echo "<li><a href='" . $SITEURL . "/viewtopic.php?f=$post->forum_id&t=$post->topic_id'>";
       				$nposts=$topic->topic_replies+1;
       				echo "$topic->topic_title\n";
       				echo "</a>\n";
       				echo " at " . date("F j, Y - H:i", $post->post_time) . " \n";
       				echo "($nposts)</li>\n";
       				if($lastfpost == $limit){ break; }
       			}
       		}
       	}
   
       	$wpdb->select($WPDB);
       }
   
       ?>
       ```
   
 * Don’t forget to edit in your correct db info and url.
 * Activate the plugin and then put this where you want it to show:
 * `<?php show_posts("5"); ?>`
 * Change the number here and in the plugin to control the number of posts.
 * You can see it live here: [http://www.sporeev.com/](http://www.sporeev.com/)
 * If anyone would feel like further enhancing this plugin I’d be thrilled. It would
   be cool to be able to exclude certain forums for example.
 *  [hellows](https://wordpress.org/support/users/hellows/)
 * (@hellows)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605828)
 * Is this working ?
    I have created a wp-phpbb-files folder, wp-phpbb.txt file 
   in it where I entered the above code and edited the phpbb DB and wp DB plus the
   URL (edited below lines)
 * $WPDB = “xxxxx”; //WP db name
    $PHPBBDB = “xxxxx”; //phpBB db name $SITEURL =“
   xxxxx”; //Forum URL with trailing /
 * changed then to .php,
    uploaded to plugin folder to my wp server, activated, 
   dded the <?php show_posts(“5”); ?> to a post and
 * nothing happens.
 *  [tbrams](https://wordpress.org/support/users/tbrams/)
 * (@tbrams)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605829)
 * Just tried it. This works out of the box – thanks to cogo
 *  [cogo](https://wordpress.org/support/users/cogo/)
 * (@cogo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605830)
 * No prob.
 * hellows, are you sure you have added the code snippet into an actual template
   file (header.php, sidebar.php or any of your choice) instead of just inserting
   it into a post?
 *  [mattsbi](https://wordpress.org/support/users/mattsbi/)
 * (@mattsbi)
 * [18 years ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605831)
 * how do you activate the plug-in? i have added <?php show_posts(“5”); ?> to index.
   php but then index.php doesnt work, can you help?
 *  [cogo](https://wordpress.org/support/users/cogo/)
 * (@cogo)
 * [18 years ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605832)
 * Just follow the instructions I posted. I don’t know what else to say since I’m
   not that clever with PHP. Sorry. Are you sure you have added all the necessary
   db settings?
 *  [mysterydad](https://wordpress.org/support/users/mysterydad/)
 * (@mysterydad)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605842)
 * Wonderful, this is exactly what I have been looking for. Tried two or three other
   possibilities and Plugins, but only this one works perfect !

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘PHPBB3 recent comments/posts in the sidebar’ is closed to new replies.

## Tags

 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [recent](https://wordpress.org/support/topic-tag/recent/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)
 * [topics](https://wordpress.org/support/topic-tag/topics/)

 * 10 replies
 * 9 participants
 * Last reply from: [mysterydad](https://wordpress.org/support/users/mysterydad/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/phpbb3-recent-commentsposts-in-the-sidebar/#post-605842)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
