解決方案:**代碼級硬編碼**,零插件、零性能損耗、全自動。
<?php
// 首頁
if ( is_home() ) {
$description = "首頁描述標簽,建議 150 字內含核心詞+品牌+價值主張";
$keywords = "核心詞1,核心詞2,品牌詞";
}
// 文章頁
elseif ( is_single() ) {
if ( $post->post_excerpt ) {
$description = $post->post_excerpt;
} else {
$description = mb_strimwidth( strip_tags( apply_filters( 'the_content', $post->post_content ) ), 0, 220 );
}
$keywords = "";
$tags = wp_get_post_tags( $post->ID );
foreach ( $tags as $tag ) { $keywords .= $tag->name . ","; }
}
// 分類頁
elseif ( is_category() ) {
$description = category_description();
}
?>
<title><?php
if ( is_home() ) { bloginfo('name'); }
elseif ( is_category() ) { single_cat_title(); echo ' - '; bloginfo('name'); }
elseif ( is_single() ) { single_post_title(); }
elseif ( is_page() ) { bloginfo('name'); echo ':'; single_post_title(); }
else { wp_title('', true); }
?></title>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<meta name="description" content="<?php echo $description; ?>" />
放入主題 `header.php` `
` 區域任意位置。**效果**:首頁固定 TDK,內頁自動提取摘要/正文前 220 字做 Description,Tags 做 Keywords,分類頁用分類描述。/%post_id% → 文章 URL 變 `domain.com/123`,**短、穩、利於收錄**;ShortPixel / EWWW Image Optimizer;WP-Optimize 定期清理修訂版/草稿/垃圾評論;技術 SEO 是地基,**地基穩了,上層建築才能蓋高**。WP 三步走讓地基在 30 分鐘內達到專業級水準,後續精力 100% 投入:
— 產出解決用戶問題的原創深度內容;
— 經營高質外鏈關係網絡;
— 數據驅動持續迭代。