一直听说 WordPress 的 All in One Seo 插件对中文支持不好。不过近几年来已经优化了不少,像 Title 标题,Keywords 关键字对中文支持已经没什么问题了,但是自动生成的 Description 描述是在是太短了。搜索了一下 All in One SEO 插件官方说明文档,发现这么一段话。

Never Shorten Long Descriptions: AIOSEO no longer shortens long descriptions. Instead it generates meta descriptions based on a standard length of 55 words defined in the_excerpt() in WordPress.

对于英文来说,55 words 基本可以占满 Google 搜索描述,但是中文是在是太短,比如这样:

所以就要修改 WP 给摘要的默认 55 个字,进入 functions.php,增加 filter

/* Excerpt Words */
function my_excerpt_length($length) {
    return 150;
}
add_filter('excerpt_length', 'my_excerpt_length');

改完这里 description 长度已经生效了,不过在文章编辑页面中,All in One SEO 插件的 description 预览还是显示 55 个字,如果强迫症犯了的话,再修改下
all-in-one-seo-pack/app/Common/Utils/Helpers.php

$postContent = wp_trim_words($postContent, 55, apply_filters('excerpt_more', ' ' . '[…]'));

将其中的 55,改为 150 即可。

最后,如果你是每篇文章自己都自己单独在插件中写 description 的强迫症狂人的话,此篇文章对你无效。谢谢!