bbp_get_topic_excerpt( int $topic_id, int $length = 100 )

Return the excerpt of the topic


Description Description


Parameters Parameters

$topic_id

(Optional) topic id

$length

(Optional) Length of the excerpt. Defaults to 100 letters

Default value: 100


Top ↑

Return Return

(string) topic Excerpt


Top ↑

Source Source

File: includes/topics/template.php

	function bbp_get_topic_excerpt( $topic_id = 0, $length = 100 ) {
		$topic_id = bbp_get_topic_id( $topic_id );
		$length   = (int) $length;
		$excerpt  = get_post_field( 'post_excerpt', $topic_id );

		if ( empty( $excerpt ) ) {
			$excerpt = bbp_get_topic_content( $topic_id );
		}

		$excerpt = trim( strip_tags( $excerpt ) );

		// Multibyte support
		if ( function_exists( 'mb_strlen' ) ) {
			$excerpt_length = mb_strlen( $excerpt );
		} else {
			$excerpt_length = strlen( $excerpt );
		}

		if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {
			$excerpt  = mb_substr( $excerpt, 0, $length - 1 );
			$excerpt .= '…';
		}

		// Filter & return
		return apply_filters( 'bbp_get_topic_excerpt', $excerpt, $topic_id, $length );
	}

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.