Out of the box, bbpress shows topics from a particular forum when you are on that forum’s archive page. Makes sense. If that forum has a sub-forum, it will link to those sub-forums, but it won’t show the actual topics from that sub-forum.
I’m trying to modify the default bbpress loop on a forum page (loop-topics.php) to include the sub-forum topics.
Here’s an explanation:
Forum A
Sub-forum A1
Sub-forum A2
Forum B
Sub-forum B1
Sub-forum B2
So when viewing Forum A’s archive page, I’d like to show topics from Forum A, sub-forum A1 and sub-forum A2.
The code needs to be dynamic in order to work with whatever parent forum archive a user is on.
You can pass wp_query args into bb_has_topics(), but I can only only come up with code that shows topics from one forum – not multiple forums.
To better explain what I’m working with, here’s an example of a loop that grabs topics from the parent forum:
<?php
$parents = get_post_ancestors( $post->ID );
$id = ($parents) ? $parents[count($parents)-1]: $post->ID;
$parent = get_page( $id );
?>
<?php $bbp_loop_args = array('post_parent' => $parent->ID, 'post_type' => 'topic'); ?>
<?php if ( bbp_has_topics($bbp_loop_args) ) : ?>
<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
<?php endwhile; ?>
<?php endif;?>
Any ideas on how this can be achieved?
Nevermind, fixed the second code, it’s missing a );
Thanks for this info!
So, the bbpress.php page worked, its loading the correct forums looking page now, no sidebar, but I can add that into this page. I see how it works.
The breadcrumbs code unfortunately does not work, causes a parse error if I try to add the second part, this one http://take.ms/JKeuq
The first part works, but if I add the second part, it breaks. If I just have the second part, it breaks….has this code become outdated?
ok, may be a little rough, but seems to work
put this in your functions file
//This function adds the author to the reply
function reply_display_author () {
global $countr ;
if ($countr == 5 ) {
echo '<span class="bbp-topic-started-by">' ;
printf( __( 'Topic started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) )) ;
echo '</span>' ;
}
else {
return ;
}
}
add_action ('bbp_theme_before_reply_content', 'reply_display_author') ;
and then create a file called bbpress in the root of your theme and copy across loop-replies.php
then amend from line 42 so that it reads
<?php if ( bbp_thread_replies() ) : ?>
<?php bbp_list_replies(); ?>
<?php else : ?>
<?php global $countr ;
$countr=-1 ; ?>
<?php while ( bbp_replies() ) : bbp_the_reply(); ?>
<?php
$countr ++ ;
<?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
<?php endwhile; ?>
<?php endif; ?>
seems to do the trick !
This dropped into your functions file puts it in every reply – just thinking about how you’re get every 5th !
//This function adds the author to the reply
function reply_display_author () {
if( get_post_type() == 'reply' ) {
echo '<span class="bbp-topic-started-by">' ;
printf( __( 'Topic started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) )) ;
echo '</span>' ;
}
else {
return ;
}
}
add_action ('bbp_theme_before_reply_content', 'reply_display_author') ;
@tonytomov I highly doubt it, a quick look at the SimplePress notes to upgrade to v5.x requires at least v4.5, have a look around and see if you can find a v4.3.1 to v4.5 upgrade, then follow the instructions to upgrade to v5.x
http://codex.simple-press.com/codex/installation/upgrading/upgrading-version-4-5/
So your test site works, but you live site doesn’t?
If there on the same servers, then it has to be a difference in either settings (database) or code.
I’d try to work out which by backing up my test site, and then restoring my live site database to it
see https://codex.bbpress.org/creating-a-test-site/
for details if you’re not familiar.
That should let you see which is it, and you can progress from there
come back and let us know how you get on
I’m grad this issue is getting worked on.
Hey Evan Herman can you please share your temporal solution code exactly as I should paste it in my functions.php
I pasted it like this but nothing happened:
$body_class = get_body_class();
if ( in_array('bbpress',$body_class) ) {
?>
<script>
jQuery(document).ready(function() {
jQuery('.menu-item-347').removeClass('current_page_parent');
jQuery('.menu-item-2592').addClass('current_page_parent');
});
</script>
<?php
}
Thanks!
I wonder if i could add a function that displays a topic starter label for any topic author in a topic.
It would be cool so that say 5 pages in a topic, you could always know who started the topic if they kept the conversation going.
I know the function would most likely be put in a theme functions.php but i wonder if it could go into loop-single-reply.php
I feel like the function would use the topic started by function, mainly get_topic_author
<span class="bbp-topic-started-by"><?php printf( __( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?></span>
IT would be a nice feature to have
any help??
Thank you, Robin.
OK, I would like to customize the line for PHP 5.2.
Where should I add this line?
Sorry, I have no knowledge of PHP code 🙁
could be done with code, but suspect not sufficient demand that anyone has coded it !
ok, php version use different code see
https://codex.wordpress.org/Widgets_API
The widget can then be registered using the widgets_init hook:
PHP 5.3+ only:
add_action( 'widgets_init', function(){
register_widget( 'My_Widget' );
});
PHP 5.2+:
add_action('widgets_init',
create_function('', 'return register_widget("My_Widget");')
);
I’m using code for 5.3 + – so if your site is using earlier, you would need to amend the line.
“Still working on the forums page and ultimately would like more control over the breadcrumb, like changing the Home URL, or removing Home alltogether, in which I’ve used another plugin to turn it into a dash.”
Layout and functionality – Examples you can use
on the forum display, still think given that it says “continue reading” I suspect that your theme is treating this as a post, and just giving what it thinks is an ‘excerpt’.
Try creating a file in the root of your theme called bbpress.php and putting the following code into it
<?php
/**
* bbPress wrapper template.
*/
get_header(); ?>
<?php while( have_posts() ): the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_footer(); ?>
put the following in your functions file
//This function changes the text wherever it is quoted
function change_translate_text( $translated_text ) {
if ( $translated_text == 'Forum' ) {
$translated_text = 'Tournaments' ;
}
return $translated_text;
}
add_filter( 'gettext', 'change_translate_text', 20 );
You would need to cut some code, but basically you would be looking at
using some code from the widget to find the latest topic
then maybe using the shotcodes
[bbp-single-topic id=$topic_id] – Display a single topic. eg. [bbp-single-topic id=4096]
and if it has a reply
[bbp-single-reply id=$reply_id] – Display a single reply eg. [bbp-single-reply id=32768]
using the do-shortcode function https://codex.wordpress.org/Function_Reference/do_shortcode
If you do this, please post the result here for the benefit of others !
That is a little disappointing 🙁
If you look at the HybridCore 1.5.5 included with the Spine 2.0 theme there is full support for bbPress built into HybridCore and for whatever reason Spine is not taking advantage of that functionality.
I just downloaded Spine and tweaked the index.php and bbpress.php files so bbPress will work with your theme, I haven’t the time to fully test if ‘everything’ works but it looks like it does. Both files go in and replace any files of the same name in the root of your theme folder e.g. /wp-content/themes/spine.
https://gist.github.com/ntwb/1d884eb7bb889906285d
You could also create a WordPress child theme to put them in which would be a little cleaner and save any pain during theme upgrades. I would expect themehybrid.com to have some tutorials on this so you can get some value for your $29 investment 😉
(Ignore some of the oddities you see in these pics,


I’ll try to take a look at this this week, there are a couple of ‘gotchas’ when running bbPress in WordPress Multisite. I’ll try to document said findings on the codex and create/update any tickets on Trac.
Just paid $29 to become a member there, hopefully their coders can resolve this soon. Thanks again guys.
‘It should work’ on a clean installation, I use a translation for approx half the sites I develop bbPress and it works perfectly. I just tested Slovak and is working as expected 🙂
I found the issue… You need to name the files bbpress-sk_SK.mo and bbpress-sk_SK.po using the _ underscore character not the - hyphen.

I have never tried the ‘Polylang’ plugin and I had a quick look in their support forums but couldn’t find any information if they support bbPress or not, maybe posting a question in their support forums may get an answer from others who have tried and had success or not, at least that way you can find out if Polylang is compatible with bbPress.
update: this was undesirable because the link to the reply was going to the reply itself, which is just a single post of the ‘reply’ custom post type. I have created this dodgy hack of the above code so the permalink for the replies is still the topic permalink. I’m sure there are a million better ways to do this, but it does the job for me so i thought i’d share the updated version.
function jag_add_last_reply() { {
$jag_last_reply_id = bbp_get_forum_last_reply_id();
$jag_last_topic_id = bbp_get_forum_last_topic_id();
$new_args = array(
'post_type'=> 'reply',
'p' => $jag_last_reply_id
);
$post_title_args = array(
'post_type'=> 'topic',
'p' => $jag_last_topic_id
);
$other_args = array(
'post_type'=> 'topic',
'p' => $jag_last_topic_id
);
$jag_query = new WP_Query( $post_title_args );
$nest_query = new WP_Query( $new_args );
$another_nest_query = new WP_Query( $other_args );
if ( $jag_query->have_posts() ) : while ( $jag_query->have_posts() ) : $jag_query->the_post();
$this_post_id=$post->ID;
$this_post_permalink= get_permalink(); ?>
<a href="<?php echo $this_post_permalink; ?>">
<?php endwhile;
endif; wp_reset_query();
if ( $nest_query->have_posts() ) : while ( $nest_query->have_posts() ) : $nest_query->the_post();
$this_post_id=$post->ID;
$this_post_title= get_the_title();
$this_post_content= get_the_excerpt(); ?>
<h1><?php echo $this_post_title; ?></h1></a>
<div class="the_content"><?php echo $this_post_content; ?></div>
<?php endwhile;
elseif ( $another_nest_query->have_posts() ) : while ( $another_nest_query->have_posts() ) : $another_nest_query->the_post();
$this_post_id=$post->ID;
$this_post_title= get_the_title();
$this_post_content= get_the_excerpt(); ?>
<h1><?php echo $this_post_title; ?></h1></a>
<div class="the_content"><?php echo $this_post_content; ?></div>
<?php endwhile;
endif;
}}
// Hook into action
add_action('bbp_theme_after_forum_description','jag_add_last_reply');
I spent so long trawling google for an answer to this question, so i am sharing what i came up with. It might not be beautiful code (i patched it together from a number of sources), but it works for me.
Basically, i have a list of forums on my forum home page. I just wanted to show the latest post within each forum as a teaser below the forum description – not just the title, but the excerpt, too. I can’t believe there’s nothing out there explaining how to do this. It seems like a pretty obvious format for the forum index.
The following snippet will output the latest reply, with post title and post link below the forum description. If there are no replies, it will output the latest topic instead.
function jag_add_last_reply() { {
$jag_last_reply_id = bbp_get_forum_last_reply_id();
$jag_last_topic_id = bbp_get_forum_last_topic_id();
$new_args = array(
'post_type'=> 'reply',
'p' => $jag_last_reply_id
);
$other_args = array(
'post_type'=> 'topic',
'p' => $jag_last_topic_id
);
$nest_query = new WP_Query( $new_args );
$another_nest_query = new WP_Query( $other_args );
if ( $nest_query->have_posts() ) : while ( $nest_query->have_posts() ) : $nest_query->the_post();
$this_post_id=$post->ID;
$this_post_title= get_the_title();
$this_post_content= get_the_excerpt();
$this_post_permalink= get_permalink(); ?>
<a href="<?php echo $this_post_permalink; ?>"><h1><?php echo $this_post_title; ?></h1></a>
<div class="the_content"><?php echo $this_post_content; ?></div>
<?php endwhile;
elseif ( $another_nest_query->have_posts() ) : while ( $another_nest_query->have_posts() ) : $another_nest_query->the_post();
$this_post_id=$post->ID;
$this_post_title= get_the_title();
$this_post_content= get_the_content();
$this_post_permalink= get_permalink(); ?>
<a href="<?php echo $this_post_permalink; ?>"><h1><?php echo $this_post_title; ?></h1></a>
<div class="the_content"><?php echo $this_post_content; ?></div>
<?php endwhile;
endif;
}}
// Hook into action
add_action('bbp_theme_after_forum_description','jag_add_last_reply');
Just put this in your theme’s functions.php and it should do the trick. Haven’t figured out how to spit out multiple posts and replies for each forum yet, but this is all i needed. Good luck.
ok, can you look at
Codex
getting started part 1, and see if anything in there helps
Come back
Anonymous User 7823331Inactive
Hello. I do not want to bother you with basics, however I tied Slovak and French translation and non of them worked.
I did everything according http://codex.bbpress.org/bbpress-in-your-language/ and no translation appears.
I downloaded translation files (po and mo) from http://translate.wordpress.org/projects/bbpress/2.5.x (bbpress-2.5.x-sk.mo, bbpress-2.5.x-sk.po), I moved the files to /wp-content/languages/bbpress/ and rename it to bbpress-sk-SK.mo and bbpress-sk-SK.po (I also tried names bbpress-sk.mo and bbpress-sk.po).
What I did wrong?
I use WP 3.5.1. with bbpress 2.5.3. I use also polylang module. All translation Slovak, France … works just the translation of bbpress do not.
Just to identify the problem I tried to install your module to WP 3.8 clear installation (with out polyalang) and same result, that translation do not appears.
I believe that it works, since you jut few people ha problem wit translation (http://bbpress.org/forums/search/translation/) but I did everything according manual and it does not work for me.
Thank you.
Dear Stephen great work! 😉
I think the last “basic” information for this great converter is “User status”
we can find it in a snitz table named FORUM_MEMBERS => M_STATUS
M_STATUS field have’s two value: 1=unlocked | 0=locked
NB: also when a user was removed / delete, will stay in the DB, with this two condition:
M_STATUS => 0
M_NAME => n/a