Support for buddypress
-
Hello
I want to migrate from yoast to AIOSEO but I have some custom buddypress code for yoast in my functions.php file. Does AIOSEO support buddypress, this is the custom code below
// Yoast SEO title fix // function buddydev_disable_wp_seo_title_filter() { if ( class_exists( 'WPSEO_Frontend' ) && is_buddypress() ) { $instance = WPSEO_Frontend::get_instance(); if ( has_filter( 'wp_title', array( $instance, 'title' ) ) ) { remove_filter( 'wp_title', array( $instance, 'title' ), 15, 3 ); } if ( has_filter( 'pre_get_document_title', array( $instance, 'title' ) ) ) { remove_filter( 'pre_get_document_title', array( $instance, 'title' ), 15 ); } } } add_action( 'bp_template_redirect', 'buddydev_disable_wp_seo_title_filter' ); // Yoast SEO title fix meta description // add_filter('wpseo_metadesc','bpdev_bp_items_metadesc'); function bpdev_bp_items_metadesc( $desc ){ // if it is not buddypress page or buddypress directory pages let the plugin do its work if( bp_is_blog_page() || bp_is_directory() ) return $desc; //we do not cover directory as directory meta can be customized from pages->Edit screen //now, let us check if we are on members page if(bp_is_user()){ //what should me the description, I am going to put it like Profile & Recent activities of [user_dsplay_name] on the site [sitename] //if you are creative, you can use some xprofile field and xprofile_get_field_data to make it better $desc = sprintf(' %s\'s Profile & Recent activities on %s ', bp_get_displayed_user_fullname(), get_bloginfo('name')); } elseif( bp_is_active( 'groups' ) && bp_is_group() ){//for single group //let us use group description $desc = bp_get_group_description(groups_get_current_group()); } //do it for other components //ok, so you can go and do the same for all the other pages //finally return the description return $desc; } /* Modify members directory title for the current member type */ function buddydev_modify_member_type_directory_title( $title ) { if ( ! bp_is_members_directory() ) { return $title; } $member_type = bp_get_current_member_type(); if ( ! $member_type ) { return $title; } $type_object = bp_get_member_type_object( $member_type ); $sep = apply_filters( 'document_title_separator', '-' ); // we are reusing the buddypress()->pages->members->id page's title, // you can call get_post() over it and do any extra manipulation $title['title'] = $title['title'] . ' ' . $sep . ' ' . $type_object->labels['name']; return $title; } add_filter( 'document_title_parts', 'buddydev_modify_member_type_directory_title', 1000 );
This code was provided by the team at https://buddydev.com/
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Support for buddypress’ is closed to new replies.