bbp_filter_modify_page_title( string $new_title = '', string $old_title = '', string $sep = '' )

Add the topic title to the <title> if viewing a single group forum topic

Description

Parameters

$new_title

(Optional) The title to filter

Default value: ''

$old_title

(Optional) (Not used)

Default value: ''

$sep

(Optional) The separator to use

Default value: ''

Return

(string) The possibly modified title

Source

File: bp-forums/functions.php

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
function bbp_filter_modify_page_title( $new_title = '', $old_title = '', $sep = '' ) {
 
    // Only filter if group forums are active
    if ( bbp_is_group_forums_active() ) {
 
        // Only filter for single group forum topics
        if ( bp_is_group_forum_topic() || bp_is_group_forum_topic_edit() ) {
 
            // Get the topic
            $topic = get_posts( array(
                'name'        => bp_action_variable( 1 ),
                'post_status' => 'publish',
                'post_type'   => bbp_get_topic_post_type(),
                'numberposts' => 1
            ) );
 
            // Add the topic title to the <title>
            $new_title .= bbp_get_topic_title( $topic[0]->ID ) . ' ' . $sep . ' ';
        }
    }
 
    // Return the title
    return $new_title;
}

Changelog

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