钩子文档

single_post_title

💡 云策文档标注

概述

single_post_title 是一个 WordPress 过滤器,用于修改单个文章页面的标题。它允许开发者在显示文章标题时进行自定义处理。

关键要点

  • 过滤器名称:single_post_title
  • 参数:$_post_title(字符串,文章标题)和 $_post(WP_Post 对象,当前文章)
  • 用法:通过 apply_filters 调用,例如 $title = apply_filters( 'single_post_title', $_post->post_title, $_post );
  • 相关函数:single_post_title() 用于显示或检索文章标题
  • 引入版本:WordPress 0.71

📄 原文内容

Filters the page title for a single post.

Parameters

$_post_titlestring
The single post page title.
$_postWP_Post
The current post.

Source

$title = apply_filters( 'single_post_title', $_post->post_title, $_post );

Changelog

Version Description
0.71 Introduced.