Getting Started in Modifying the Main bbPress Template
If you are just picking up bbPress and you want to make some basic changes to the template that is being rendered like say removing WordPress comments code or any post meta that should only be shown on blog posts, then please follow this guide.
On a plain vanilla install of bbPress , the plugin looks for the following templates from your current active WordPress theme in and “injects” the forum into the first one it finds.
It will find any of the page templates with the names listed below.
For WordPress themes it is most commonly going to inject the forum code into the page.php file. To find the exact file install the plugin What The File and go to your bbPress forums section of your site and check your WordPress Toolbar and see what the exact file to modify is.
You can then copy the file you found and rename it to any of the file names listed above and make sure it is in your themes root directory.
wp-content/themes/%mytheme%/bbpress.php where %mytheme% is your currently active theme’s name.
It is recommended to use a child theme so that you do not lose any changes on the next update of your theme.
After all that you can customize the new bbpress.php file to remove any unwanted code/design your bbPress forums and the bbPress plugin should pick up that template and render all of its pages using that custom template.
Please read the comments in the code.
<?php /** * The template for displaying all bbPress pages * * This is the template that displays all bbPress pages by default. * Please note that this is the template of all bbPress pages * and that other 'pages' on your WordPress site will use a * different template. * * @package WordPress * @subpackage Theme */ /* Self explanatory its a functions that gets your header template. */ get_header(); ?> /* Surrounding Classes for the site These are different every theme and help with structure and layout These could be SPANs or DIVs and with entirely different classes. */ <div id="primary" class="site-content"> <div id="content" role="main"> /* Start the Loop */ <?php while ( have_posts() ) : the_post(); ?> /* This is the start of the page and also the insertion of the post classes. Post classes are very handy to style your forums. */ <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> /* This is the title wrapped in a header tag and a class to better style the title for your theme */ <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header> /* This is the content wrapped in a div and class to better style the content */ <div class="entry-content"> <?php the_content(); ?> </div> <!-- .entry-content --> /* End of Page */ </article> <!-- #post --> <?php endwhile; // end of the loop. ?> </div> <!-- #content --> </div> <!-- #primary --> /* This is code to display the sidebar and the footer. Remove the sidebar code to get full-width forums. This would also need CSS to make it actually full width. */ <?php get_sidebar(); ?> <?php get_footer(); ?>
Another way to render custom template code for your bbPress forums is to use conditional tags like is_bbpress() inside of a PHP if statement.
Here is an example.
<?php if ( is_bbpress() ) : ?> <div class="abc"> This content should show if it is bbPress </div> <?php else : ?> <div class="xyz"> This should show if it is not bbPress </div> <?php endif; ?>