BBP_Shortcodes::display_view( array $attr, string $content = '' )
Display the contents of a specific view in an output buffer and return to ensure that post/page contents are displayed first.
Description
Parameters
- $attr
-
(Required)
- $content
-
(Optional)
Default value: ''
Return
(string)
Source
File: bp-forums/common/shortcodes.php
public function display_view( $attr, $content = '' ) {
// Sanity check required info
if ( empty( $attr['id'] ) )
return $content;
// Set passed attribute to $view_id for clarity
$view_id = $attr['id'];
// Start output buffer
$this->start( 'bbp_single_view' );
// Unset globals
$this->unset_globals();
// Set the current view ID
bbpress()->current_view_id = $view_id;
// Load the view
bbp_view_query( $view_id );
// Output template
bbp_get_template_part( 'content', 'single-view' );
// Return contents of output buffer
return $this->end();
}
Changelog
| Version | Description |
|---|---|
| bbPress (r3031) | 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.