Your secret spy resident for Linux, web server and hardware

Buddypress with yoast plugin. Incorrect canonical url.

Not so long time ago I’ve completely disappointed with All in One SEO Pack plugin which I usually use for SEO purpose. Previously it has many feature which were easy executable by adding another plugins of the top of All in One SEO Pack, but with each new version they transferred slowly into professional version, making my existing All in One SEO Pack nonfunctional after it’s upgrade or upgrade other plugins. So I completely moved to Yoast SEO. So it was like a new level of SEO management for WordPress, but unfortunately not for buddypress which was installed in my several project. The main headache appeared to be with Buddypress groups and Buddypress members. Every group and member profiles processed by Yoast generates in code incorrect canonical url, usually chopped to http://yoursite.com/members, but not http://yoursite.com/members/membername, what causes complete exclusion for scanning by Google and other search engines.

I’m not a PHP developer, but after tearful researches I found where to make changes to fix buddypress yoast  canonical.

So I edited theme function.php

# Yoast canonical for buddypress

function wpseo_canonical_exclude( $canonical ) {
global $bp;
if ( $bp->current_component) {
$canonical = false;
}
return $canonical;
}
add_filter( 'wpseo_canonical', 'wpseo_canonical_exclude' );

# end of yoast canonical for buddypress

 

Now all my groups and members are properly processed by Yoast SEO. Great thanks for developer who made this plugin. I hope you will take it in account for the future version.

Exit mobile version