Have you seen bbp_new_topic_pre_title()
in includes/topics/functions.php
?
(There’s also bbp_new_forum_pre_title()
in includes/forums/functions.php
)
Hi,
Thanks for the response. I’m not following how this would solve the problem, though. From what I can see of that filter, I need to pass in the topic title into this function, but I can’t get the topic title in functions.php early enough.
Here’s the function (in functions.php) I’ve created to modify the title in other ways needed (replace “Forum” with “Investment Groups” and replace mdash; with a hyphen as the main separator). This is where I’d want to incorporate the logic:
function theme_mod_title() {
add_filter('document_title_separator', function() {
return '$%';
});
remove_filter('pre_get_document_title', 'theme_mod_title');
$find = array(
'/ \$% /',
'/^Forums/'
);
$replace = array(
' - ',
'Investment Groups'
);
$title = wp_get_document_title();
// filter the title
$ftitle = preg_replace($find, $replace, $title);
NOT SURE HOW TO ACCOMPLISH THIS, BUT LOGIC NEEDED IS
//if (on bbpress topic page){
$ftitle = bbpress topic title . ' - ' . $ftitle;
//}
return $ftitle;
}
add_filter('pre_get_document_title', 'theme_mod_title');
The bbPress part is where I’m stuck. I’m not sure how to actually get the topic title early enough to pass it into the document title. This seems to be the only place I can actually set any new meta title tag logic, but I can’t tap into anything bbPress this early in the process.
Thanks again
Thinking about this in another way, would you be able to point me in the direction of where the “Forum” and “Group Name” portions of the meta title are being set?
Current output to the title tag is: “<title>Forum – [Group Name] – Site Name</title>”. For my purposes, I could either tap into whatever function is setting the “Forum” or “Group Name” to prepend the topic name.
Thanks again
Hi,
Hate to be a bother, and I can imagine you get a million questions, but this is the only thing holding me back from launching a site I’ve been working on for 9 months, so I’m pulling my hair out over here. Any help would be appreciated. It seems like no one has been able to solve for this, given my extensive Googling on the subject.
Yoast and any other SEO plugins aren’t compatible and just output blank, so that is not an option. Is there any way at all to access the topic title to add to the page title on bbPress topic pages?
Thanks