本文约 6,340 字,预计阅读 16 分钟。文中命令与配置均经过实测,可直接参考执行。
引言:专题页是资讯站最值钱的资产
一个刚发布的新闻,流量曲线是尖峰形的:当天高,三天后归零。但一个做得好的专题页是阶梯形的:每次事件有新的进展,页面更新一次,流量再上一个台阶,搜索引擎对它的权重判断也随之累积。这就是为什么同样的内容量,有的站能做起来有的做不起来——差别在有没有把相关内容聚合成”资产”。专题页要成为资产,必须满足三个条件:内容是自动收录的(不需要人工维护)、有稳定的 URL 与标题结构、有区别于列表页的独特内容(导语、时间线、观点)。
原理分析:专题不是标签,是”有编辑意志的聚合”
很多站长把专题直接做成标签页。这会导致两个问题:一是标签页没有编辑导语,本质上是另一个列表页,容易被搜索引擎判为低质量;二是标签会无限膨胀,产生大量只有一个内容的空页面。
正确做法是用独立的自定义分类法 topic,专门为”专题”服务,并且每个专题支持编辑填写封面图、导语、时间线。技术上利用 WordPress 的模板层级:分类法 topic 会自动匹配 taxonomy-topic.php,不存在则回落到 taxonomy.php → archive.php → index.php。这给了我们一个干净的落点,不用写条件判断。
| 方案 | 优点 | 缺点 |
|---|---|---|
| 用标签做专题 | 零开发 | 无导语,易产生空页,权重分散 |
| 用分类做专题 | 有层级 | 与栏目体系混淆 |
独立分类法 topic |
模板独立、字段可扩展 | 需少量开发 |
收录规则是专题页的灵魂。常见规则有:topic 分类法直接指派(编辑手动勾选)、按标签自动归入(同标签自动进专题)、按关键词自动归入(正文命中即归入)。三种可以叠加,但手动指派优先级最高。
保姆级实操
步骤 1:注册 topic 分类法,并绑定到文章。 注意 show_in_rest => true,方便后续用区块编辑器或前端调用。
add_action( 'init', 'mimangfei_register_topic_taxonomy' );
function mimangfei_register_topic_taxonomy() {
register_taxonomy( 'topic', array( 'post' ), array(
'labels' => array( 'name' => '专题', 'singular_name' => '专题' ),
'public' => true,
'hierarchical' => false,
'show_in_rest' => true,
'rewrite' => array( 'slug' => 'topic' ),
'capabilities' => array(
'manage_terms' => 'manage_categories',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts',
),
) );
}
步骤 2:给专题加编辑字段。 专题需要封面图、导语、状态(进行中/已完结)。分类法没有内置的编辑界面扩展点,用 topic_edit_form_fields 与 edited_topic 两个钩子补齐。
add_action( 'topic_edit_form_fields', 'mimangfei_topic_extra_fields' );
function mimangfei_topic_extra_fields( $term ) {
$lead = get_term_meta( $term->term_id, '_topic_lead', true );
$status = get_term_meta( $term->term_id, '_topic_status', true );
?>
<tr class="form-field">
<th scope="row"><label for="mmf_topic_lead">专题导语</label></th>
<td><textarea name="mmf_topic_lead" id="mmf_topic_lead" rows="4" cols="50"><?php echo esc_textarea( $lead ); ?></textarea></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="mmf_topic_status">专题状态</label></th>
<td>
<select name="mmf_topic_status" id="mmf_topic_status">
<option value="ongoing" <?php selected( $status, 'ongoing' ); ?>>进行中</option>
<option value="closed" <?php selected( $status, 'closed' ); ?>>已完结</option>
</select>
</td>
</tr>
<?php
}
add_action( 'edited_topic', 'mimangfei_save_topic_fields' );
function mimangfei_save_topic_fields( $term_id ) {
if ( isset( $_POST['mmf_topic_lead'] ) ) {
update_term_meta( $term_id, '_topic_lead', sanitize_textarea_field( wp_unslash( $_POST['mmf_topic_lead'] ) ) );
}
if ( isset( $_POST['mmf_topic_status'] ) ) {
update_term_meta( $term_id, '_topic_status', sanitize_key( $_POST['mmf_topic_status'] ) );
}
}
步骤 3:写自动收录规则。 文章发布时,如果它的标签命中了某个专题配置的”关联标签”,就自动归入。这样编辑只管打标签,专题自动更新。
add_action( 'save_post', 'mimangfei_auto_assign_topic', 20, 2 );
function mimangfei_auto_assign_topic( $post_id, $post ) {
if ( wp_is_post_revision( $post_id ) || 'publish' !== $post->post_status ) {
return;
}
$tags = wp_get_post_tags( $post_id, array( 'fields' => 'ids' ) );
if ( empty( $tags ) ) {
return;
}
$topics = get_terms( array( 'taxonomy' => 'topic', 'hide_empty' => false ) );
foreach ( $topics as $topic ) {
$linked = (array) get_term_meta( $topic->term_id, '_linked_tags', true );
$linked = array_map( 'intval', $linked );
if ( array_intersect( $tags, $linked ) ) {
wp_set_object_terms( $post_id, array( $topic->term_id ), 'topic', true ); // true = 追加
}
}
}
步骤 4:建 taxonomy-topic.php 模板。 模板里按”导语 → 时间线 → 文章列表 → 相关专题”的顺序组织,文章列表按发布时间倒序并做分组(按天)。
// taxonomy-topic.php 片段
$term = get_queried_object();
$lead = get_term_meta( $term->term_id, '_topic_lead', true );
$args = array(
'post_type' => 'post',
'posts_per_page' => 20,
'tax_query' => array(
array(
'taxonomy' => 'topic',
'field' => 'term_id',
'terms' => $term->term_id,
),
),
);
$query = new WP_Query( $args );
步骤 5:处理收录与排序。 专题页应被索引,但分页从第二页起加 noindex,避免大量薄分页。排序上,把”最新进展”放在最前,符合读者预期。
add_action( 'wp_head', 'mimangfei_topic_pagination_noindex' );
function mimangfei_topic_pagination_noindex() {
if ( ! is_tax( 'topic' ) ) {
return;
}
$paged = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
if ( $paged > 1 ) {
echo '<meta name="robots" content="noindex,follow">' . "\n";
}
}
步骤 6:加结构化数据与面包屑。 专题页用 CollectionPage 类型标注,配合面包屑能提升搜索结果的展现形式。
{
"@context": "https://schema.org",
"@type": "CollectionPage",
"name": "专题名称",
"description": "专题导语内容",
"url": "https://example.com/topic/demo/",
"mainEntity": {
"@type": "ItemList",
"numberOfItems": 20,
"itemListElement": []
}
}
步骤 7:控制专题数量。 只有预计会产生 10 篇以上内容的话题才建专题,否则就是给自己制造空页面。定期用 wp term list 检查空专题并清理。
# 列出所有专题及其文章数,count 为 0 的考虑清理
wp term list topic --fields=term_id,name,slug,count --format=table
常见踩坑
- 专题手工维护列表。 编辑一忙就忘记更新,专题变成”死页”,正确做法是自动收录。
- 专题数量失控。 只有两三篇文章也建专题,产生大量低质量页面,稀释站点整体质量分。
- 专题页与标签页内容重复。 同一组文章在两个 URL 下重复出现,需要明确 canonical 指向专题页。
- 案例: 某站把所有专题都做成了标签页,三年下来积累 900 多个标签,其中 600 多个只有 1–2 篇文章。搜索引擎抓取预算被大量空标签页消耗,主内容收录速度明显下降。改成独立
topic分类法并把空标签批量合并后,新内容的收录周期从平均 5 天缩短到 1 天。 - 分页未加 noindex。 专题分页无限深,产生海量薄内容。
- 自动收录规则无限递归。
save_post里调用wp_set_object_terms又触发save_post,必须加防重入判断或调整优先级并做条件收敛。 - 专题导语为空。 没有独特内容的专题页与列表页无异,很难拿到排名。
总结
专题页的合格标准是三条:内容自动收录、有编辑撰写的独特导语、分页受控。技术上用独立 topic 分类法拿到独立模板,用 save_post + 标签映射实现自动归类,用 is_tax() 判断加分页 noindex。判断标准:一个专题是否值得建,看它未来能否积累 10 篇以上内容。首页信息流如何配合专题分发见杂志资讯站首页设计;文档类站点的层级组织见WordPress 文档站实现。
