Questions titles not working

5.78K viewsCoreissue title
1

Hi Rahul,

I added ANSPRESS_TITLE to the title area of the base page as specified but it is not picking up the individual page titles in the browser tabs.

Here is an example – [PRIVATE LINK] (you can see it is showing ANSPRESS_TITLE in the browser tab)

How to fix this?

Thanks

0

Did you installed Yoast ? if yes then you have to update or if you dont want to update to unstable version then add this hooks in

includes/class-theme.php

add this inside __construct method:

add_filter('wpseo_title', array( $this, 'wpseo_title' ) , 10, 2);

And now add this method to class:

public function wpseo_title($title){
	if (is_anspress())
	{
		remove_filter('wpseo_title', array($this,'wpseo_title'));

		$new_title = ap_page_title();

		if(strpos($title, 'ANSPRESS_TITLE') !== false)
			$new_title = str_replace('ANSPRESS_TITLE', $new_title, $title). ' | ' . get_bloginfo( 'name' );
		else
			$new_title = $new_title.' | '. get_bloginfo( 'name' );

		$new_title = apply_filters('ap_wpseo_title', $new_title);
		
		return $new_title;
	}
	return $title;
}

Just uploaded the unstabled version and that fixed the problem however it turns out like this now: Sample question for north america | Backpacker Travel | Backpacker Travel (the last part doubles up)

Will check.

Tell me where to make these changes?
“includes / class-theme.php” – it “anspress” folder or in a folder with the theme of your site?
“public function wpseo_title ($ title)” – and this is where?

Please have a look at github repository. I directly copied it from includes/class-theme.php

Good! I replaced the file and it worked! Thanks! )