bp_modify_page_title( string $title = '', string $sep = '»', string $seplocation = 'right' )
Filter the page title for BuddyPress pages.
Description
See also
Parameters
- $title
-
(Optional) Original page title.
Default value: ''
- $sep
-
(Optional) How to separate the various items within the page title.
Default value: '»'
- $seplocation
-
(Optional) Direction to display title.
Default value: 'right'
Return
(string) New page title.
Source
File: bp-core/bp-core-filters.php
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 | function bp_modify_page_title( $title = '' , $sep = '»' , $seplocation = 'right' ) { global $paged , $page , $_wp_theme_features ; // Get the BuddyPress title parts. $bp_title_parts = bp_get_title_parts( $seplocation ); // If not set, simply return the original title. if ( ! $bp_title_parts ) { return $title ; } // Get the blog name, so we can check if the original $title included it. $blogname = get_bloginfo( 'name' , 'display' ); /** * Are we going to fake 'title-tag' theme functionality? * * @see wp_title() */ $title_tag_compatibility = (bool) ( ! empty ( $_wp_theme_features [ 'title-tag' ] ) || ( $blogname && strstr ( $title , $blogname ) ) ); // Append the site title to title parts if theme supports title tag. if ( true === $title_tag_compatibility ) { $bp_title_parts [ 'site' ] = $blogname ; if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() && ! bp_is_single_activity() ) { $bp_title_parts [ 'page' ] = sprintf( __( 'Page %s' , 'buddyboss' ), max( $paged , $page ) ); } } // Pad the separator with 1 space on each side. $prefix = str_pad ( $sep , strlen ( $sep ) + 2, ' ' , STR_PAD_BOTH ); // Join the parts together. $new_title = join( $prefix , array_filter ( $bp_title_parts ) ); // Append the prefix for pre `title-tag` compatibility. if ( false === $title_tag_compatibility ) { $new_title = $new_title . $prefix ; } /** * Filters the older 'wp_title' page title for BuddyPress pages. * * @since BuddyPress 1.5.0 * * @param string $new_title The BuddyPress page title. * @param string $title The original WordPress page title. * @param string $sep The title parts separator. * @param string $seplocation Location of the separator (left or right). */ return apply_filters( 'bp_modify_page_title' , $new_title , $title , $sep , $seplocation ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.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.