I hope the following patches will help some people. The only trouble is that the patches work with WordPress SEO Version 1.2.3 but not with the two newer versions: WordPress SEO Version 1.2.4 or 1.2.5 Something changed moving to WordPress SEO 1.2.4 and it would be great if @ Joost de Valk could help to fix this please, so we can keep with the latest WordPress SEO. Please let me know Joost. Many thanks.
I’ve managed to get WordPress SEO Version 1.2.3 working quite nicely with Buddypress (latest versions up to and including Buddypress 1.6 Beta 2) and Buddypress Docs (latest version 1.1.24) on WordPress 3.4.1. The WordPress SEO box appears fine for all Buddypress Docs and allows me to enter the SEO titles and meta description OK. Unfortunately, this WordPress SEO box doesn’t even show for WordPress SEO Versions 1.2.4 and 1.2.5 and I’d love a fix to this please – see above.
I then use the code below in my functions.php. Any improvements gratefully accepted as I am new to coding. Thanks to: https://www.generalthreat.com/2012/04/extending-buddypress-group-hierarchy-adding-breadcrumbs-to-your-theme/ for pointing me in the right direction on this.
add_filter( 'bp_modify_page_title', 'marc_hierdoc_title', 10, 4 );
function marc_hierdoc_title( $hierdoc_title, $title, $sep, $seplocation ) {
global $bp, $wp_query, $post, $wpseo, $bp_docs;
if( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) ) {
/** Remove the name of the group from the title*/
$hierdoc_title = substr( $hierdoc_title, strpos( $hierdoc_title, '|' ) );
/** Add the full group hierarchy to the title */
$hierdoc_title = bp_group_hierarchy_get_full_name( '|', $bp->groups->current_group) . ' ' . $hierdoc_title;
/** If BP Doc then replace title with title input via Yoast WordPress SEO plugin */
} if ( bp_docs_is_existing_doc() && bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) ) {
$doc = bp_docs_get_current_doc();
$doc_id = $doc->ID;
$hierdoc_title= get_post_meta( $doc->ID, _yoast_wpseo_title, true);
}
return $hierdoc_title;
}
add_action('wp_head', 'marc_doc_metadesc');
function marc_doc_metadesc( $doc_metadesc ) {
global $bp, $wp_query, $post, $wpseo, $bp_docs;
if ( bp_docs_is_existing_doc() && bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) ) {
$doc = bp_docs_get_current_doc();
$doc_id = $doc->ID;
$doc_metadesc= get_post_meta( $doc->ID, _yoast_wpseo_metadesc, true);
$doc_metadesc="<meta name=\"description\" content=\"$doc_metadesc\">";
}
echo $doc_metadesc;
}