How to show latest phpBB3 posts in your WordPress sidebar
As you may notice, at the top of the rightmost column of this blog I am showing the latest posts of the forum.
I did not find any widget fitting my needs so I had to solve the problem by myself. And I am going to tell you how.
At the moment it’s not a widget, just a bunch of lines in a PHP Code Widget to do the trick. Should I receive good feedback, I will develop a fully customizable widget.
Anyway, following this tutorial will make you able to show your phpBB3 posts in your WP sidebar in a matter of minutes.
First, in your WP admin area go to Presentation -> Widgets to go into Sidebar Arrangement section.
You should find a screen like this one

… but it may be a bit different according to your theme. Anyway, what you need is a PHP Code Widget, so have to create one (look at the bottom arrow in the image) and drag/drop it in the sidebar.
Then you’re ready to enter the code in your widget:
1 2 3 4 5 6 7 8 9 10 | <?php $connection = mysql_connect(localhost,"your_login","your password") or die("Service temporairly unavailable"); $db = mysql_select_db("your_db_name",$connection) or die("Service temporairly unavailable"); $sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10"; $result = mysql_query($sql) or die("Service temporairly unavailable"); for($x=1;$x<=10;$x++){ $row = mysql_fetch_array($result); echo "<a href = \"http://www.yourforumdomain.com/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br>"; } ?> |
Line 1: Opening php tag. Normally it makes no difference between <? and >?php but my widget told me
PHP Code MUST be enclosed in tags!
Line 2: Connecting with the database where you are hosting your phpBB3. Change localhost with the address of your database, your_login with database login and your_password with your database password. In case something should fail (database is down, login or password are incorrect), I return a “Service temporairly unavaiable” and terminate the script.
Line 3: Selecting the database where you installed your phpBB3. Change your_db_name with the name of the database.
If you do not remember one (or more) data explained at lines 2-3, simply give a look to your config.php file in the folder where you installed phpBB3.
It’s made in this way:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php // phpBB 3.0.x auto-generated configuration file // Do not change anything in this file! $dbms = 'mysql'; $dbhost = '122.122.122.122'; $dbport = ''; $dbname = 'emanuele'; $dbuser = 'triqui'; $dbpasswd = 'banana'; $table_prefix = 'phpbb_'; $acm_type = 'file'; $load_extensions = ''; @define('PHPBB_INSTALLED', true); // @define('DEBUG', true); // @define('DEBUG_EXTRA', true); ?> |
At line 5 you will find the database address (122.122.122.122), at line 7 db name (emanuele), at line 8 db username (triqui) and at line 9 the password (banana).
Also remember line 11 and write down somewhere the content of table_prefix variable (phpbb_)
I did not used any of those names, so don’t even try to hack my forum… but let’s go back to the script…
Line 4: This is the string representing the query that will create the table with the last 10 updated topcis. phpbb_topics is the name of the table than contains the topics. If you have another value in your table_prefix variable, then you will need to change phpp_topics with your_table_prefix_topics. So, as an example, if your table prefix is triqui, then your table name will be triqui_topics, while you won’t have to change topic_last_post_time that represents the timestamp of the last post in the topic. In this way, you will get a table with the latest 10 topic ordered by last post time. If you want more (or less) than 10 topics, change the 10 in limit 0,10
Line 5: Processing the query, or returning in case of error the same fake message “Service temporairly unavaiable”
Line 6: Loop to be executed 10 times
Line 7: Fetching the row of the table in an array called row
Line 8: Displaying the link: notice that the link starts with http://www.yourforumdomain.com/, you will have to change this address with the path of your phpBB3 forum. For instance, if your forum is in the forum folder in the google domain, you will have to write http://www.google.com/forum/. You don’t need to change anything else
That’s all. Hope you will find it useful… maybe some day I will make a widget that will be easier to configure.
You will be pleasantly surprised by WordPress Themes provided by Template Monster. All of them are of professional design and high quality.
39 Responses to “How to show latest phpBB3 posts in your WordPress sidebar”
Leave a Reply
- Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines – 17 lines version
- Sell sitelocked version of your Flash games and even .fla sources to Free Online Games
- Protect your work from ActionScript code theft with SWF Protector
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines
- Understanding Box2D’s one-way platforms, aka CLOUDS
- Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2
- Box2D Flash game creation tutorial – part 2
- 11 Flash isometric engines you can use in your games
- Monetize your Flash games with GamesChart
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Triqui MochiAds Arcade plugin for WordPress official page
- Create a flash artillery game - step 1
- Flash game creation tutorial – part 5.2 (4.88/5)
- Create a flash artillery game – step 1 (4.79/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a flash artillery game – step 2 (4.74/5)
- Create a survival horror game in Flash tutorial – part 1 (4.73/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 2 (4.71/5)
- Flash game creation tutorial – part 1 (4.70/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)
- Creation of a platform game with Flash – step 2 (4.68/5)

(10 votes, average: 4.20 out of 5)





I know a guy who used this in his page…
I think he was called Emanuele… and it was very cool to see the latest posts without having to go to the forum, I think you should use it, Emanuele
;)
Sorry to be fussy, but you put: or die(“Service temporairly unavaiable”);
There is a typo, should be: available.
Anyway, great idea – its really useful!
Thanks. Fixed.
Hi Emanuele, I have recently been making a game based on your ball game with visual from above tutorial. I would like you to put it on your website if that is possible. I have changed the background and the tiles, and have made some types of my own. These include the “rollercoaster tiles” which hurtle you in the direction they are pointing, and a few other surprises. Your tutorials are brilliant and without them I would really be stuck with actionscript.
I am making a website, but I don’t know how to get my phpBB posts/topics into my mySQL server. How do I do this? Did you already show how?
Thanks a bunch.
thanks to this post. it’s my first time to see that it you can show the latest forum posts on my blog. :)
It doesn’t make you lose a lot of time but since it is MySQL, you could put “Limit 0, 10″ at the end of your query.
That’s what I did, Monkios
I am having issues with this. I implemented exactly how you stated and the widget works fine and does display the latest forum posts but all the other widgets below this widget in my sidebar are no longer displaying their data. Any idea why?
I have the problem that i see the title of the widgetfine but not any latest topics?? any tricks to fix?
I get this error
Parse error: parse error, unexpected T_STRING in /home/content/html/example.php on line 7
Which is this line:
$row = mysql_fetch_array($result);
Could you help me?
Hi Emanuele -
This is great!! This helped me out a ton, thank you so much!
I have multiple phpbb3 boards running out of one database (I use different prefix’s to distinguish them all).. Can you think of a way to modify your code so that I can display the past 10 topics out of all of my boards, and not just one specific prefix?
I appreciate your help!
Hello again,
I was actually able to figure out how to select the correct topics using the following SQL statement:
select * from prefix1_topics
UNION ALL
select * from prefix2_topics
UNION ALL
select * from prefix3_topics
order by topic_last_post_time desc limit 0,10
Is that the best way to accomplish this?
Now I cannot seem to figure out a way to direct the users after they click on a topic to the correct board. In other words I need to somehow modify your line to the appropriate board:
echo “$row[topic_title]“;
The problem I am having is in the bottom section where I am trying to link to the correct topic. I cannot figure out a way to have the topic link to the correct board. How can I make it so that http://prefix.mysite.com matches the correct prefix from my SQL query?
Hi and thanks for the code. Helped me, both from tearing the hair off my head and a lot of time to make this myself.
Just wondering about one thing. I’ve got part of a forum that is hidden from “normal users” (an admin forum), and this comes up on the frontpage! Would it be possible to attach some code that makes only “visible” forums appear on the frontpage?
Thanks in advance!
Hello!
I think this try.
Hi, great mod, but I have the same query as tanketom. How do I prevent titles of posts in private forums from being displayed?
I know it can be done, as I have mods within phpBB that do exactly that, but my knowledge of php isn’t good enough to port the code across into a Wordpress sidebar. :-(
Would this work for Phpbb2?
We’re having issues with 3…
Wow. It is working. Well done. I am so happy now. I have been looking for this for a long time.
NOTE: This php is working for 2.5+ worspress but you must istall a php widget plugin so that you can use this code.
PS: How can I get the topic names to change color when I roll over them with a mouse. something like a flash highlight ?
Congratulations one more time!
UPDATE. Make a widget out of it or a plugin. This will be so popular eith the WP users as all other plugins in the WP plugin section are not wotking.
+ make the phpBB use the WP databes so a user will have to only login once. This will be so popular. thanks :>
I have the problem that i see the title of the widgetfine but not any latest topics?? any tricks to fix?
You also spelled “temporarily” wrong…
lol, banana.
hi ,
I have similar problem.
I want to add some information from my forum to be displayed on my homepage.
Information is like current user , latest member name etc ..
I dn’t kno how to do it ..
can you help me…
one more thing , in your given code , what will happen if topics are less than 10 ??
use
while ($row = mysql_fetch_array($result)){
echo “forum post link”;
}
instead.
Also, instead of putting numbers alongside your code, use and ordered list to achieve the same effect without us having to delete it from your code.
Thanks for the small snippet of code that allowed me to not do any work. :) Using it on http://www.hiptop3.com in the sidebar.
this code just destroyed my site. I also cannot remove the widget anymore in my Dashboard.
Please help fast.
Hi!
I would like make better my SQL capabilities.
I red so many SQL resources and still feel, that I am not an expert
in SQL. What would you recommend?
Thanks,
Werutz
I have a flash site
i’m looking for the script who of google ads on flash.
how can i get it?
did you mean http://flashsense.t35.com/ ?
Hello
I have an idea to set my Photo as avatar. But I have some problems when upload my photo.
Some times it does not upload at all. Or when I upload the photo, the photo has some deformation.
What should I do to fix that?
Thanks a lot
Hi. can it be used for joomla site? i tried but nothing apiers in my panel on my site…can somebody help me? thanks
waahahahahaha.. thanks a lot!
This works great on my Joomla site!
thanks again!
Nothing seems to be easier than seeing someone whom you can help but not helping.
I suggest we start giving it a try. Give love to the ones that need it.
God will appreciate it.
can you help me? I don’t know whay should i do
i dont noob!
how to show the post with utf8 support?
Please, make this WP plugin.
Hi,
I tried a lot of those PHP codes to show last posts on my page … but this one only works for me :-) … THX!!
I’m not using WordPress, but I manage to implement. But now I have “local” issue. In Slovenia we are using “ŠČŽ – funny letters :-)” and I have problem showing them. OK just one letter “ÄŒ”. You can look on my page (www.drp-drustvo.si) under “..:: Sveže na forumu ::..” (light yellow notes) …
Thx in advance and thx again for really useful code!
Regards, Marko
This is a cool idea but there’s a security issue in here. Actually, you don’t need a password from the database and username, all you should have is msql server so the script can retrieve info/topics last 5 posts…etc
UTF-8 Support please….
How can it be done?