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
- bp_get_template_part(): for a description of $slug, $name and $args params.
Parameters 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
- $args
-
(Optional) See bp_get_template_part().
Default value: array()
Return Return
(string|null) If $echo, returns the template content.
Source 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 Changelog
Version | Description |
---|---|
7.0.0 | Added $args parameter. |
1.7.0 | Introduced. |