bbp_get_topic( $topic,  $output = OBJECT,  $filter = 'raw' )

Gets a topic


Description Description


Return Return

(mixed) Null if error or topic (in specified form) if success


Top ↑

Source Source

File: includes/topics/template.php

function bbp_get_topic( $topic, $output = OBJECT, $filter = 'raw' ) {

	// Maybe get ID from empty or int
	if ( empty( $topic ) || is_numeric( $topic ) ) {
		$topic = bbp_get_topic_id( $topic );
	}

	// Bail if no post object
	$topic = get_post( $topic, OBJECT, $filter );
	if ( empty( $topic ) ) {
		return $topic;
	}

	// Bail if not correct post type
	if ( $topic->post_type !== bbp_get_topic_post_type() ) {
		return null;
	}

	// Default return value is OBJECT
	$retval = $topic;

	// Array A
	if ( $output === ARRAY_A ) {
		$retval = get_object_vars( $topic );

	// Array N
	} elseif ( $output === ARRAY_N ) {
		$retval = array_values( get_object_vars( $topic ) );
	}

	// Filter & return
	return apply_filters( 'bbp_get_topic', $retval, $topic, $output, $filter );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.