bp_buffer_template_part( string $slug, string|null $name = null, bool $echo = true, array $args = array() )

Put a template part into an output buffer, and return it.


Description Description

See also See also


Top ↑

Parameters Parameters

$slug

(string) (Required) See bp_get_template_part().

$name

(string|null) (Optional) See bp_get_template_part().

Default value: null

$echo

(bool) (Optional) If true, template content will be echoed. If false, returned. Default: true.

Default value: true

$args

(array) (Optional) See bp_get_template_part().

Default value: array()


Top ↑

Return Return

(string|null) If $echo, returns the template content.


Top ↑

Source Source

File: bp-core/bp-core-template-loader.php

function bp_buffer_template_part( $slug, $name = null, $echo = true, $args = array() ) {
	ob_start();

	// Remove 'bp_replace_the_content' filter to prevent infinite loops.
	remove_filter( 'the_content', 'bp_replace_the_content' );

	bp_get_template_part( $slug, $name, $args );

	// Remove 'bp_replace_the_content' filter to prevent infinite loops.
	add_filter( 'the_content', 'bp_replace_the_content' );

	// Get the output buffer contents.
	$output = ob_get_clean();

	// Echo or return the output buffer contents.
	if ( true === $echo ) {
		echo $output;
	} else {
		return $output;
	}
}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Added $args parameter.
1.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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