Filtering Title in BuddyPress
-
I’m working on filtering titles for BuddyPress pages (specifically, Groups and Group Forums). I’m having some trouble so maybe someone can ppint me in the right direction
Since 4.1, WordPress has deprecated the
wp_title()
function, and instead developers should use thedocument_title_parts
filter. The filter is documented in the Code Reference, and an example using this filter can be seen here.I’ve successfully used this filter on my very basic Twentysixteen child theme, but that method doesn’t seem to adopt to a Group page template I created and the forums that I’ve created and assigned under them. Here was a basic hack I used for testing purposes:
// output a custom title for Groups & Forums function custom_groups_title( $title ){ if ( bp_is_group() ){ $group_name = bp_get_current_group_name(); if ( bp_current_action() == 'forum') { $group_name .= " Chatboard"; } $title['title'] = $group_name . ' | Awesome Website, Inc.'; $title['site'] = ''; $title['tagline'] = ''; } return $title; } add_filter('document_title_parts', 'custom_groups_title', 10);
the title is not getting filtered at all, so I guess BuddyPress is bypassing or overriding this filter.
Can anyone point me in the right direction for filtering the title?
- You must be logged in to reply to this topic.