bbp_get_forum_class( int $forum_id,  $classes = array() )

Return the row class of a forum

Description

Parameters

$forum_id

(Optional) Forum ID

(Optional) Extra classes you can pass when calling this function

Return

(string) Row class of the forum

Source

File: bp-forums/forums/template.php

	function bbp_get_forum_class( $forum_id = 0, $classes = array() ) {
		$bbp       = bbpress();
		$forum_id  = bbp_get_forum_id( $forum_id );
		$count     = isset( $bbp->forum_query->current_post ) ? $bbp->forum_query->current_post : 1;
		$classes   = (array) $classes;

		// Get some classes
		$classes[] = 'loop-item-' . $count;
		$classes[] = ( (int) $count % 2 )                      ? 'even'              : 'odd';
		$classes[] = bbp_is_forum_category( $forum_id )        ? 'status-category'   : '';
		$classes[] = bbp_get_forum_subforum_count( $forum_id ) ? 'bbp-has-subforums' : '';
		$classes[] = bbp_get_forum_parent_id( $forum_id )      ? 'bbp-parent-forum-' . bbp_get_forum_parent_id( $forum_id ) : '';
		$classes[] = 'bbp-forum-status-'     . bbp_get_forum_status( $forum_id );
		$classes[] = 'bbp-forum-visibility-' . bbp_get_forum_visibility( $forum_id );

		// Ditch the empties
		$classes   = array_filter( $classes );
		$classes   = get_post_class( $classes, $forum_id );

		// Filter the results
		$classes   = apply_filters( 'bbp_get_forum_class', $classes, $forum_id );
		$retval    = 'class="' . implode( ' ', $classes ) . '"';

		return $retval;
	}

Changelog

Changelog
Version Description
bbPress (r2667) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.