bp_buffer_template_part( string $slug, string|null $name = null, bool $echo = true )
Put a template part into an output buffer, and return it.
Description
See also
- bp_get_template_part(): for a description of $slug and $name params.
Parameters
- $slug
-
(Required) See bp_get_template_part().
- $name
-
(Optional) See bp_get_template_part().
Default value: null
- $echo
-
(Optional) If true, template content will be echoed. If false, returned. Default: true.
Default value: true
Return
(string|null) If $echo, returns the template content.
Source
File: bp-core/bp-core-template-loader.php
function bp_buffer_template_part( $slug, $name = null, $echo = true ) { 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 ); // 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; } }
Changelog
Version | Description |
---|---|
BuddyPress 1.7.0 | 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.