BuddyPress 1.0 home 页默认的title 是”博客标题 — Home”,比如SinoBlog.net 首页的浏览器标题就是”SinoBlog.net — Home”。
Home 对网站/博客而言,其实没有任何意义,网页的title 对于搜索引擎的收录非常重要,所以需要将其修改。
BuddyPress title 的修改方法是,打开”/bp-core/bp-core-templatetags.php”,大概是从第468 行开始定义title 的。
我就只修改了SinoBlog.net 首页的title,如下:
- function bp_page_title() {
- global $bp, $post, $wp_query;
- if ( is_home() && bp_is_page( 'home' ) ) {
- $title = __( '免费提供专业WordPress 博客服务', 'buddypress' );
- } else if ( bp_is_blog_page() ) {
- if ( is_single() ) {
- $title = __( 'Blog — ' . $post->post_title, 'buddypress' );
- } else if ( is_category() ) {
- $title = __( 'Blog — Categories — ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );
- } else if ( is_tag() ) {
- $title = __( 'Blog — Tags — ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );
- } else {
- $title = __( 'Blog', 'buddypress' );
- }
- } else if ( !empty( $bp->displayed_user->fullname ) ) {
- $title = strip_tags( $bp->displayed_user->fullname . ' — ' . ucwords( $bp->current_component ) . ' — ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'] );
- } else if ( $bp->is_single_item ) {
- $title = ucwords( $bp->current_component ) . ' — ' . $bp->bp_options_title;
- } else if ( $bp->is_directory ) {
- if ( !$bp->current_component )
- $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
- else
- $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
- } else {
- global $post;
- $title = get_the_title($post->ID);
- }
- echo apply_filters( 'bp_page_title', get_blog_option( BP_ROOT_BLOG, 'blogname' ) . ' — ' . $title, $title );
- }
记录一下,因为title 以后可能还需要修改