bbp_title( string $title = '', string $sep = '»', string $seplocation = '' )

Custom page title for Forums pages

Description

Parameters

$title

(Optional) The title (not used).

Default value: ''

$sep

(Optional) default is '»'. How to separate the various items within the page title.

Default value: '»'

$seplocation

(Optional) Direction to display title, 'right'.

Default value: ''

Return

(string) The tite

Source

File: bp-forums/common/template.php

2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
function bbp_title( $title = '', $sep = '»', $seplocation = '' ) {
 
    // Title array
    $new_title = array();
 
    /** Archives **************************************************************/
 
    // Forum Archive
    if ( bbp_is_forum_archive() ) {
        $new_title['text'] = bbp_get_forum_archive_title();
 
    // Topic Archive
    } elseif ( bbp_is_topic_archive() ) {
        $new_title['text'] = bbp_get_topic_archive_title();
 
    /** Edit ******************************************************************/
 
    // Forum edit page
    } elseif ( bbp_is_forum_edit() ) {
        $new_title['text']   = bbp_get_forum_title();
        $new_title['format'] = esc_attr__( 'Forum Edit: %s', 'buddyboss' );
 
    // Topic edit page
    } elseif ( bbp_is_topic_edit() ) {
        $new_title['text']   = bbp_get_topic_title();
        $new_title['format'] = esc_attr__( 'Discussion Edit: %s', 'buddyboss' );
 
    // Reply edit page
    } elseif ( bbp_is_reply_edit() ) {
        $new_title['text']   = bbp_get_reply_title();
        $new_title['format'] = esc_attr__( 'Reply Edit: %s', 'buddyboss' );
 
    // Topic tag edit page
    } elseif ( bbp_is_topic_tag_edit() ) {
        $new_title['text']   = bbp_get_topic_tag_name();
        $new_title['format'] = esc_attr__( 'Discussion Tag Edit: %s', 'buddyboss' );
 
    /** Singles ***************************************************************/
 
    // Forum page
    } elseif ( bbp_is_single_forum() ) {
        $new_title['text']   = bbp_get_forum_title();
        $new_title['format'] = esc_attr__( 'Forum: %s', 'buddyboss' );
 
    // Topic page
    } elseif ( bbp_is_single_topic() ) {
        $new_title['text']   = bbp_get_topic_title();
        $new_title['format'] = esc_attr__( 'Discussion: %s', 'buddyboss' );
 
    // Replies
    } elseif ( bbp_is_single_reply() ) {
        $new_title['text']   = bbp_get_reply_title();
 
    // Topic tag page
    } elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) {
        $new_title['text']   = bbp_get_topic_tag_name();
        $new_title['format'] = esc_attr__( 'Discussion Tag: %s', 'buddyboss' );
 
    /** Users *****************************************************************/
 
    // Profile page
    } elseif ( bbp_is_single_user() ) {
 
        // User is viewing their own profile
        if ( bbp_is_user_home() ) {
            $new_title['text'] = esc_attr_x( 'Your', 'User viewing his/her own profile', 'buddyboss' );
 
        // User is viewing someone else's profile (so use their display name)
        } else {
            $new_title['text'] = sprintf( esc_attr_x( "%s's", 'User viewing another users profile', 'buddyboss' ), get_userdata( bbp_get_user_id() )->display_name );
        }
 
        // User topics created
        if ( bbp_is_single_user_topics() ) {
            $new_title['format'] = esc_attr__( "%s Discussions",        'buddyboss' );
 
        // User rueplies created
        } elseif ( bbp_is_single_user_replies() ) {
            $new_title['format'] = esc_attr__( "%s Replies",       'buddyboss' );
 
        // User favorites
        } elseif ( bbp_is_favorites() ) {
            $new_title['format'] = esc_attr__( "%s Saved",     'buddyboss' );
 
        // User subscriptions
        } elseif ( bbp_is_subscriptions() ) {
            $new_title['format'] = esc_attr__( "%s Subscriptions", 'buddyboss' );
 
        // User "home"
        } else {
            $new_title['format'] = esc_attr__( "%s Profile",       'buddyboss' );
        }
 
    // Profile edit page
    } elseif ( bbp_is_single_user_edit() ) {
 
        // Current user
        if ( bbp_is_user_home_edit() ) {
            $new_title['text']   = esc_attr__( 'Edit Your Profile', 'buddyboss' );
 
        // Other user
        } else {
            $new_title['text']   = get_userdata( bbp_get_user_id() )->display_name;
            $new_title['format'] = esc_attr__( "Edit %s's Profile", 'buddyboss' );
        }
 
    /** Views *****************************************************************/
 
    // Views
    } elseif ( bbp_is_single_view() ) {
        $new_title['text']   = bbp_get_view_title();
        $new_title['format'] = esc_attr__( 'View: %s', 'buddyboss' );
 
    /** Search ****************************************************************/
 
    // Search
    } elseif ( bbp_is_search() ) {
        $new_title['text'] = bbp_get_search_title();
    }
 
    // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
    $new_title = apply_filters( 'bbp_raw_title_array', $new_title );
 
    // Set title array defaults
    $new_title = bbp_parse_args( $new_title, array(
        'text'   => $title,
        'format' => '%s'
    ), 'title' );
 
    // Get the formatted raw title
    $new_title = sprintf( $new_title['format'], $new_title['text'] );
 
    // Filter the raw title
    $new_title = apply_filters( 'bbp_raw_title', $new_title, $sep, $seplocation );
 
    // Compare new title with original title
    if ( $new_title === $title )
        return $title;
 
    // Temporary separator, for accurate flipping, if necessary
    $t_sep  = '%WP_TITILE_SEP%';
    $prefix = '';
 
    if ( !empty( $new_title ) )
        $prefix = " $sep ";
 
    // sep on right, so reverse the order
    if ( 'right' === $seplocation ) {
        $new_title_array = array_reverse( explode( $t_sep, $new_title ) );
        $new_title       = implode( " $sep ", $new_title_array ) . $prefix;
 
    // sep on left, do not reverse
    } else {
        $new_title_array = explode( $t_sep, $new_title );
        $new_title       = $prefix . implode( " $sep ", $new_title_array );
    }
 
    // Filter and return
    return apply_filters( 'bbp_title', $new_title, $sep, $seplocation );
}

Changelog

Changelog
Version Description
bbPress (r2788) 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.