Skip to:

Re: How to get a section identifier in the body tag?



I guess I shouldn’t have led you down the Sandbox road!

I should have said look at those functions as a structure… don’t use it literally as most of that code is WP-specific only.

As for these lines:

global $bp;
echo $bp->current_component; //outputs current component
echo $bp->current_action; // outputs current action

They are BP-specific and will let you determine what type of BP page you’re on (except for directories)… try it by putting the lines in the header.php of your BP member theme.

I would use the lines in your new CSS class function like this:

function bp_body_class( $print = true ) {
global $bp;

if ( bp_is_page( BP_MEMBERS_SLUG ) )
$c[] = 'members';

//more conditionals here

$c[] = $bp->current_component; //outputs current component
$c[] = $bp->current_action; // outputs current action

// Separates classes with a single space, collates classes for BODY
$c = join( ' ', apply_filters( 'body_class', $c ) ); // Available filter: body_class

// And tada!
return $print ? print($c) : $c;

Something to that effect in your bp theme’s functions.php file.

That’s basically 90% of the function right there.

Skip to toolbar