WordPress

How To Fix BuddyPress Titles When Using Yoast SEO

BuddyPress + Yoast SEO = Heaven

Yoast SEO is the most popular SEO plugin on the market and their team is renowned as some of the most experienced and reliable SEO’s in the world. That being said, BuddyPress the “social network in a box” of WordPress has some very well known compatibility issues when Yoast is enabled.

The primary issue that you will come across is that Yoast and BuddyPress don’t play well together and this has been a problem for many years now and its partially due to both plugins. The primary reason for this is that BuddyPress uses a non-standard way of delivering titles and Yoast SEO has no way of managing it. The reason for this is because Yoast hooks into physical pages while BuddyPress uses dynamic pages for each user which doesn’t work well with Yoast.

To solve this problem you can still use Yoast SEO and you will need to be able to access a child theme functions.php file or your own site specific plugin. The code snippet which can be viewed below will remove the rewrite ability that Yoast SEO for titles on all BuddyPress related pages. This will not affect any non-buddypress pages and it will not work with any other SEO plugins. This code should also be placed in your own site-specific plugin in order to work across themes.

/**
 * Removes WordPress SEO Title Filter On BuddyPress Pages
 *
 * @version 1.0.0
 * @since 1.0.0
 * @return void
 */

if ( defined('BP_VERSION') ) {

function sert_remove_bp_wpseo_title() {
 if ( function_exists( 'wpseo_auto_load' ) && function_exists( 'bp_is_blog_page' ) && ! bp_is_blog_page() ) {
 $wpseo_instance = WPSEO_Frontend::get_instance();
 remove_filter( 'pre_get_document_title', array( $wpseo_instance, 'title' ), 15 );
 }
 }
 add_action( 'init', 'sert_remove_bp_wpseo_title' );
 }

After you have added this code to your website BuddyPress titles should start showing correctly and this is without the use of an additional plugin. The best part is the plugin does a check for BuddyPress and Yoast so if either is accidentally disabled you won’t get any errors!

Tags
Show More

Scott Hartley

Scott Hartley is the developer and owner of The Daily Exposition who is also a tech enthusiast and writes the majority of content found on the website. When he isn't keeping up to date with the latest and breaking technology news, he is working on his own WordPress plugins, themes, or out exploring the world.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close