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:
"; } ?>
Line 1: Opening php tag. Normally it makes no difference between
>?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:
At line 5 you will find the database address (18.104.22.168), 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
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
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
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.