bp_modify_document_title_parts( array $title = array() )
Filter the document title for BuddyPress pages.
Description
Parameters
- $title
-
(Optional) The WordPress document title parts.
Default value: array()
Return
(array) the unchanged title parts or the BuddyPress ones
Source
File: bp-core/bp-core-filters.php
function bp_modify_document_title_parts( $title = array() ) {
// Get the BuddyPress title parts.
$bp_title_parts = bp_get_title_parts();
// If not set, simply return the original title.
if ( ! $bp_title_parts ) {
return $title;
}
// Get the separator used by wp_get_document_title().
$sep = apply_filters( 'document_title_separator', '-' );
// Build the BuddyPress portion of the title.
// We don't need to sanitize this as WordPress will take care of it.
$bp_title = array(
'title' => join( " $sep ", $bp_title_parts )
);
// Add the pagination number if needed (not sure if this is necessary).
if ( isset( $title['page'] ) && ! bp_is_single_activity() ) {
$bp_title['page'] = $title['page'];
}
// Add the sitename if needed.
if ( isset( $title['site'] ) ) {
$bp_title['site'] = $title['site'];
}
/**
* Filters BuddyPress title parts that will be used into the document title.
*
* @since BuddyPress 2.4.3
*
* @param array $bp_title The BuddyPress page title parts.
* @param array $title The original WordPress title parts.
*/
return apply_filters( 'bp_modify_document_title_parts', $bp_title, $title );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.4.3 | 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.