function bigfa_description() {
global $s, $post;
$description = '';
$blog_name = get_bloginfo('name');
if ( is_singular() ) {
$ID = $post->ID;
$title = $post->post_title;
$author = $post->post_author;
$user_info = get_userdata($author);
$post_author = $user_info->display_name;
if (!get_post_meta($ID, "meta-description", true)) {$description = $title.' - 作者: '.$post_author.',首发于'.$blog_name;}
else {$description = get_post_meta($ID, "meta-description", true);}
} elseif ( is_home () ) { $description = ""; // 首页要自己加,如果你主题有后台设置可以连接上
} elseif ( is_tag() ) { $description = single_tag_title('', false) . " - ". trim(strip_tags(tag_description()));
} elseif ( is_category() ) { $description = single_cat_title('', false) . " - ". trim(strip_tags(category_description()));
} elseif ( is_archive() ) { $description = $blog_name . "'" . trim( wp_title('', false) ) . "'";
} elseif ( is_search() ) { $description = $blog_name . ": '" . esc_html( $s, 1 ) . "' 的搜索結果";
} else { $description = $blog_name . "'" . trim( wp_title('', false) ) . "'";
}
$description = mb_substr( $description, 0, 220, 'utf-8' );
echo "\n";
}
add_action('wp_head','bigfa_description');