Skip to:
Content
Pages
Categories
Search
Top
Bottom
Codex HomeBuddyPress Theme DevelopmentBP Theme Compatibility and the WordPress Default Themes → Twenty Thirteen Theme

Twenty Thirteen Theme

A. One column Layout

One Column Layout. Click on image to enlarge.

One Column Layout. Click on image to enlarge.

This is the default layout of the Twenty Thirteen theme if and only if you do not add any widget in the Secondary Widget area in Appearance > Widgets. Otherwise, the Twenty Thirteen theme will automatically have a two-column layout if you add widget to the Secondary Widget area.

If you want to add widgets in the Secondary Widget area for your site’s pages/posts but would prefer a one-column layout for all BP pages, following are the steps to do so.

1. Create a child theme of the Twenty Thirteen theme.

2. Create a new file in your new child theme folder and name it buddypress.php.

3. Copy over the content of Twenty Thirteen’s page.php file into the new buddypress.php file. Remove the get_sidebar tag just before the get_footer call in the template.

<?php
/**
 * BuddyPress: One column template
 *
 * A One column template for all BuddyPress pages.
 *
 * @ since Twenty Twelve 1.3 and BuddyPress 1.9 beta 1
 */
get_header(); ?>

	<div id="primary" class="site-content">
		<div id="content" role="main">
			<?php while ( have_posts() ) : the_post(); ?>
				<?php get_template_part( 'content', 'page' ); ?>
			<?php endwhile; // end of the loop. ?>
		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_footer(); ?>

4. Create a blank functions.php file in the folder of your child theme if you don’t have one yet. You will need to remove the .sidebar body class generated if any widget is added to the Secondary Widget Area which would move the alignment of the content area away from the center,

5. Add the following to the new functions.php file then save file.

<?php
// Remove sidebar body class from BuddyPress pages
function mme_remove_sidebar_body_class($wp_classes) {
	if( function_exists ( 'bp_loaded' ) && !bp_is_blog_page() ) :
		foreach($wp_classes as $key => $value) {
			 if ($value == 'sidebar') unset($wp_classes[$key]);
		}
	endif;
	return $wp_classes;
}
add_filter('body_class', 'mme_remove_sidebar_body_class', 20, 2);

6. Upload your Twenty Thirteen child theme folder to server.

B. Full Width Layout

Full-width Layout. Click on image to enlarge.

Full-width Layout. Click on image to enlarge.

You can create a full-width layout for all BP pages even when the Secondary Widget Area (right sidebar) is active for rest of the site by following these steps.

1. Create a child theme of the Twenty Thirteen theme.

2. Create a new file in your new child theme folder and name it buddypress.php.

3. Copy over the content of Twenty Thirteen’s page.php file into the new buddypress.php file. Remove the get_sidebar tag just before the get_footer call in the template as well as the section with the call to post_thumbnail and save file.

<?php
/**
 * BuddyPress: Full-width Page Template, No Sidebar
 *
 * A full-width template for all BuddyPress pages.
 *
 * @ since Twenty Twelve 1.3 and BuddyPress 1.9 beta 1
 */
get_header(); ?>

	<div id="primary" class="site-content">
		<div id="content" class="full-width" role="main">
			<?php while ( have_posts() ) : the_post(); ?>
				<?php get_template_part( 'content', 'page' ); ?>
			<?php endwhile; // end of the loop. ?>
		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_footer(); ?>

4. Create a blank functions.php file in the folder of your child theme if you don’t have one yet. You will need to remove the sidebar body class generated if any widget is added to the Secondary Widget Area which would show up in regular blog posts/pages,

5. Add the following to your new functions.php file then save file.

<?php
// Remove sidebar body class in BuddyPress pages
function mme_remove_sidebar_body_class($wp_classes) {
	if( function_exists ( 'bp_loaded' ) && !bp_is_blog_page() && is_active_sidebar( 'sidebar-2' ) ) :
		foreach($wp_classes as $key => $value) {
			 if ($value == 'sidebar') unset($wp_classes[$key]);
		}
	endif;
	return $wp_classes;
}
add_filter('body_class', 'mme_remove_sidebar_body_class', 20, 2);

6. Open up your child theme’s style.css file, add the following and save file.

.buddypress .entry-header,
.buddypress .entry-content,
.buddypress .entry-summary,
.buddypress .entry-meta {
	max-width: 1040px;
	width: 100%;
}

@ media (max-width: 1069px) {
	.buddypress .entry-header,
	.buddypress .entry-content,
	.buddypress .entry-summary,
	.buddypress .entry-meta {
		padding-left: 20px;
		padding-right: 20px;
	}
}

– delete the space between @ and media in media query above.

7. Upload your Twenty Thirteen child theme folder to server.

C. Two Column, Right Sidebar Layout

Two-column Layout. Click on image to enlarge.

Two-column Layout. Click on image to enlarge.

When you add any widget to the Secondary Widget Area in Appearance > Widgets using the Twenty Thirteen theme, the right sidebar will automatically show up in all posts and pages including the BuddyPress pages. So if you plan to have the same widgets in the right sidebar throughout the site, then you can stop reading at this point as you will not have to do anything further.

However, if you want to customize the sidebar content of all your BP pages, you can do so by: a) using a plugin like Widget Logic to assign widgets to specific pages by using conditional tags or b) by creating new buddypress.php and sidebar-buddypress.php files and then registering a new widget area in your child theme’s functions.php file. The following steps are for the second option.

1. Create a child theme of the Twenty Thirteen theme.

2. Create a new file in your new child theme folder and name it buddypress.php.

3. Copy over the content of Twenty Thirteen’s page.php file into a new buddypress.php file and remove the section about retrieving the post_thumbnail. Then you will have to change get_sidebar() to get_sidebar(‘buddypress’).

<?php
/**
 * BuddyPress: two-column template.
 *
 * A two-column template for all BP pages.
 *
 * @ since Twenty Thirteen 1.1 and BuddyPress 1.9 beta 1
 */
get_header(); ?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">

			<?php while ( have_posts() ) : the_post(); ?>

				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<header class="entry-header">
						<h1 class="entry-title"><?php the_title(); ?></h1>
					</header><!-- .entry-header -->

					<div class="entry-content">
						<?php the_content(); ?>
						<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
					</div><!-- .entry-content -->

					<footer class="entry-meta">
						<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
					</footer><!-- .entry-meta -->
				</article><!-- #post -->

			<?php endwhile; ?>

		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_sidebar('buddypress'); ?>
<?php get_footer(); ?>

4. Create a blank functions.php file in the folder of your child theme if you don’t have one yet. You will be creating a new widget area for BuddyPress pages as well as adding a body class to help you style your two column layout.

5. Add the following to the new functions.php file then save file.

<?php
// Add new widget area for BuddyPress pages
function mme_register_bp_widgets_area() {
	register_sidebar( array(
		'name'		 => __( 'BuddyPress Sidebar Widget Area', 'mmechildtheme' ),
		'id' 		 => 'bp-sidebar',
		'description'	 => __( 'Appears in the sidebar section of all BuddyPress pages.', 'mmechildtheme' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'	=> '</aside>',
		'before_title'	=> '<h3 class="widget-title">',
		'after_title'	=> '</h3>',
	) );
}
add_action( 'widgets_init', 'mme_register_bp_widgets_area' );

// Add the sidebar body class for BP pages if the Secondary Widget area is not active
function mme_add_sidebar_body_class( $classes ) {
	if ( function_exists ( 'bp_loaded' ) &&  !bp_is_blog_page() && !is_active_sidebar( 'sidebar-2' )  )  {
		$classes[] = 'sidebar';
	}
	return $classes;
}
add_filter( 'body_class', 'mme_add_sidebar_body_class' );

6. Create a new file named sidebar-buddypress.php in your child theme folder and add the following:

<?php
/**
 * The sidebar containing the BuddyPress widget area
 *
 * Displays on BP pages.
 *
 * If no active widgets are in this sidebar, nothing will show up in your sidebar.
 *
 * @ since Twenty Thirteen 1.1 and BuddyPress 1.9 beta 1
 */
if ( is_active_sidebar( 'bp-sidebar' ) ) : ?>

	<div id="tertiary" class="sidebar-container" role="complementary">
		<div class="sidebar-inner">
			<div class="widget-area">
				<?php dynamic_sidebar( 'bp-sidebar' ); ?>
			</div><!-- .widget-area -->
		</div><!-- .sidebar-inner -->
	</div><!-- #tertiary -->

<?php endif; ?>

8 . Upload your Twenty Thirteen child theme folder to server. You’ll need to add at least one widget to the BP Sidebar widget area.

Skip to toolbar