List of topics of a particular bbPress forum
November 14th, 2009 | Tagged as: bbPress ¤ CMS ¤ WordPress | Download as PDFIf you are new here. You may want to sign up for e-mail updates or subscribe to my RSS feeds. Thanks for visiting!
This tutorial will demonstrate the usage of custom queries so as to show topics of a certain bbPress forum along with Topic starter and Last Poster of inside WordPress. Before you can play around with bbPress information, you need to integrate WordPress with bbPress. After integration you can place this code anywhere in your template and it will fetch information from bbPress tables.
<div id="bbpress_forumlist">
<table id="forumlist">
<thead>
<tr>
<th>Topics</th>
<th>Author</th>
<th>Last Reply by</th>
</tr>
</thead>
<tbody>
<?php
$forum_id = 7;
$limit = 5;
global $wpdb;
$query = "SELECT topic_title,topic_poster_name,topic_last_poster_name FROM life_topics WHERE forum_id = ".$forum_id." LIMIT ".$limit;
$topicslist = $wpdb->get_results($query,"ARRAY_N");
if(!$topicslist)
echo "err";
else
{
foreach( $topicslist as $topicslist )
{
echo '<tr>';
echo '<td>'.$topicslist[0].'</td>';
echo '<td>'.$topicslist[1].'</td>';
echo '<td>'.$topicslist[2].'</td>';
echo '</tr>';
}
}
?>
</tbody>
</table>
</div>
This is a very basic demonstration of fetching the data in a simple table. You need to change the forum_id to the id of your forums (Look into your database via phpMyAdmin) on line 12, change the no of topics to display on line 13 and change the bbPress table prefix in query on line 15.
You can also make your titles hyperlinked with the topic slug by fetching topic_slug from the database and generating the URL as per your permalinks setup. Doing this goes beyond the scope of this simple tutorial. You can also fetch topic_time to display the time in another column of the table. Just add CSS classes to style the table via CSS.
Have anything to ask or more to implement. Feel free to ask in the comments! Make sure you check out other tutorials to show bbPress content inside WordPress & the whole WordPress as CMS series.






Howdy! My name is Ashish K Saini aka Ashfame.

Hi Ashish, this could be just what I’m looking for. I’ve got a bbPress setup with ten forums for students at different levels. I’d like to be able to have ten WordPress pages, each one showing the topics, posts and topic starter for a particular bbPress forum, so that Module One students can only access the Module One forum and so on, and will still see the WordPress sidebar and widgets.
Is this possible??? And how would I do it!!!
Your advice appreciated
Linda
PS I have integrated my WordPress 3.0 with bbPress.
Yes! You can do that. Read this post – http://blog.ashfame.com/2009/11/show-bbpress-content-inside-wordpress/
Hi Ashfame, I read the post but am not sure how to make it work so that on WP Page 1 visitors will only see the links for bbPress Forum 1, Page 2 visitors will only see the links for bbPress Forum 2 and so on.
Any idea if this can be done?
Thanks
Linda
Hi Linda,
Yes, you can do that and that’s what I have shown in the example. The forum ID will fetch the details of a particular forum only.
If all this is technical to you, then you can hire me to do the job.
Thanks
Ashfame
Hi Ashfame, I’d be glad to give you a donation if I can get it to work. I’m just a bit confused where you say to put the code in the template. If it goes in the theme’s page template then I don’t see how you can get different pages to show different forum links. I tried just pasting it into the html window of a test page but when I clicked on Preview it was just gobbledegook!
Your advice appreciated
Linda
The code needs to be inside WordPress.
Create a page template and copy paste this php code in it and fill forum is by checking your database.
Also both WordPress and bbPress needs to be installed in the same database.
Are you also trying to limit the access to other forums or just show the concerned one?
I think its better that we talk on this via email or IM.
Sending you an email.