bbp_get_topic_class( int $topic_id,  $classes = array() )

Return the row class of a topic

Description

Parameters

$topic_id

(int) (Optional) Topic id

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

Return

(string) Row class of a topic

Source

File: bp-forums/topics/template.php

	function bbp_get_topic_class( $topic_id = 0, $classes = array() ) {
		$bbp       = bbpress();
		$topic_id  = bbp_get_topic_id( $topic_id );
		$count     = isset( $bbp->topic_query->current_post ) ? $bbp->topic_query->current_post : 1;
		$classes   = (array) $classes;
		$classes[] = ( (int) $count % 2 )                    ? 'even'         : 'odd';
		$classes[] = bbp_is_topic_sticky( $topic_id, false ) ? 'sticky'       : '';
		$classes[] = bbp_is_topic_super_sticky( $topic_id  ) ? 'super-sticky' : '';
		$classes[] = 'bbp-parent-forum-' . bbp_get_topic_forum_id( $topic_id );
		$classes[] = 'user-id-' . bbp_get_topic_author_id( $topic_id );
		$classes   = array_filter( $classes );
		$classes   = get_post_class( $classes, $topic_id );
		$classes   = apply_filters( 'bbp_get_topic_class', $classes, $topic_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.