Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How can I edit the size and style of each forum separately?

@robin-w

Moderator

ok, so 3 stages

1. create the style.css entries – say you have a forum called ‘fred’ you might want to create a ‘fred’ style and have content for this eg

.fred #fixed-background { background: url(‘http://www.mysite.com/wp-content/uploads/2015/02/fredbackground.jpg’); }

2. look up the forum’s ID

go to dashboard>forums>all forums and hover over the ‘edit’

at the bottom of the screen you’ll see

http://www.mysite.com/wp-admin/post.php?post=2921&action=edit

in this case 2921 is the forum ID

3. add the style to the body class for that forum

Add this into your functions file

function rew_add_class ($classes, $bbp_classes, $wp_classes, $custom_classes ) {
	//the above line pulls in the pre-existing values so we don't lose them - ie run this function using this existing $variables if they exist
	//then we check is this is a forum using a bbpress function
	if ( bbp_is_single_forum() ) {
	$bbp_forum_id = bbp_get_forum_id();
	if ($bbp_forum_id == 2922) $custom_classes[] = 'fred' ;
	if ($bbp_forum_id == 2923) $custom_classes[] = 'george' ;
}

	//then we check is this is a topic using a bbpress function
	if ( bbp_is_single_topic() ) {
	//and if so look up the forum id of that topic
	$bbp_forum_id = bbp_get_topic_forum_id();
	//now you will need to add lines for each forum you have and say which class class you want to use, these are just example lines.  Add one for each forum
	//the number is the 'page_id' (actually it's the post id !)
	if ($bbp_forum_id == 2922) $custom_classes[] = 'fred' ;
	if ($bbp_forum_id == 2923) $custom_classes[] = 'george' ;
		}
	//then this gets merges into the existing wordpress and bbpress classes
	$classes = array_merge (  (array) $classes, (array) $custom_classes ) ;
	Return apply_filters( 'rew_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes ) ;
}

add_filter ('bbp_body_class' , 'rew_add_class') ; 

Skip to toolbar