Skip to:

Re: Extending WordPress Themes – Post Experiences



My approach is kind of weird.


I needed a custom BP framework. So I started looking at the old Skeleton Theme. The first thing I noticed is that I didn’t want a fixed layout BP theme, so I removed all sidebars in each template file and wrapped the content inside a function.

This means that every template file of my BP theme was something like this:

/* my license ... GPL2 of course :) */

function this_file_content() {
just the content of the page, without sidebars

my_layout_generator( 'this_file_content' );

The magic is in my_layout_generator, which defines the html layout of each page. This includes sidebars and other stuff. The sidebars are fully widgetized, and I have custom widgets like “BP Options Bar” and “BP User Bar”, etc. Their content is also managed through actions.

my_layout_generator can mimic any WordPress theme, you just have to write the “skeleton layout” of your target theme.


This BP framework must be integrated with the WP theme. I setup the framework as child-theme and the original WP theme as parent theme.

Considering this, my_layout_generator has the following body (simplified from the original):

function my_layout_generator( $content_func = '' ) {

<div id="container">
if ( !empty( $content_func ) && is_callable( $content_func ) )
call_user_func( $content_func );
<div id="sidebars">
<?php // your sidebars code ?>


This uses the original theme headers and footers. I just need to provide the correct markup in the content!

There are other things to care about, like page title. Probably the header of the original theme uses wp_title instead of the BP title. Luckily, wp_title can be filtered! This is actual code from my framework:

add_filter( 'wp_title', 'gs_wp_title' );
// we need to put the current page title on the wp_title filter, so thesis will catch it
function gs_wp_title($title, $sep = '', $seplocation = '') {
if ( bp_is_blog_page() )
return $title;

global $bp;

if ( !empty( $bp->displayed_user->fullname ) ) {
$title = strip_tags( $bp->displayed_user->fullname . ' — ' . ucwords( $bp->current_component ) . ' — ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'] );
} else if ( $bp->is_single_item ) {
$title = ucwords( $bp->current_component ) . ' — ' . $bp->bp_options_title;
} else if ( $bp->is_directory ) {
if ( !$bp->current_component )
$title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
$title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );

return $title;

Now we have an integrated BP theme framework :) Mine is integrated with Thesis, I think other themes will be much easier to integrate because you can directly copy their layouts from their template files.

Skip to toolbar