Skip to:

Re: Here’s how to show bbPress info inside WordPress without full integration



So we have the $results, how do we make a pretty list of them, say inside of our sidebar?

We have to loop through them and print them out. This is where that list of fields inside of bb_topics comes in handy.

Here’s just a list of titles to start with:

foreach ($results as $result) {
echo "<li>".$result->topic_title."</li>";

Of course that’s not very useful, because they aren’t clickable. To make them clickable will take a little bit more work:

foreach ($results as $result) {
echo "<li><a href='/forums/topic.php?id=".$result->topic_id."'>".$result->topic_title."</a></li>";

That example uses quite a few shortcuts to get the job done, it hardcoded the path to your forums (change /forums/ if needed) and even if your bbPress uses pretty permalinks, it simply uses the topic id number to get there – bbPress will redirect back to permalinks. If you absolutely know you have permalinks and want to use them, you could have done something like this instead:

<a href='/forums/topic/".$result->topic_slug."'>"

Skip to toolbar