Quantcast
Channel: bbPress.org » All Posts
Viewing all articles
Browse latest Browse all 3646

Reply To: Adding single topic title into meta title for SEO

$
0
0

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


Viewing all articles
Browse latest Browse all 3646

Trending Articles