钩子文档

default_content

💡 云策文档标注

概述

default_content 过滤器用于修改在“撰写文章”表单中初始使用的默认文章内容。它允许开发者在文章创建时自定义默认内容。

关键要点

  • 过滤器名称:default_content
  • 参数:$post_content(字符串,默认文章内容)和 $post(WP_Post 对象)
  • 应用场景:在 get_default_post_to_edit() 函数中调用,用于填充“撰写文章”表单的初始内容
  • 版本历史:自 WordPress 1.5.0 版本引入

代码示例

$post->post_content = (string) apply_filters( 'default_content', $post_content, $post );

📄 原文内容

Filters the default post content initially used in the “Write Post” form.

Parameters

$post_contentstring
Default post content.
$postWP_Post
Post object.

Source

$post->post_content = (string) apply_filters( 'default_content', $post_content, $post );

Changelog

Version Description
1.5.0 Introduced.