钩子文档

the_title_export

💡 云策文档标注

概述

本文档介绍了 WordPress 中的 'the_title_export' 过滤器,它用于在生成 WXR 导出文件时过滤文章的标题。开发者可以通过此 Hook 自定义导出标题的内容。

关键要点

  • 'the_title_export' 是一个过滤器,应用于 WXR 导出中的文章标题。
  • 参数 $post_title 是当前文章的标题字符串。
  • 此过滤器在 export_wp() 函数中被调用,用于生成 WXR 导出文件。
  • 从 WordPress 5.7.0 版本开始引入。

代码示例

$title = wxr_cdata( apply_filters( 'the_title_export', $post->post_title ) );

注意事项

  • 此过滤器仅影响 WXR 导出文件中的标题,不影响前端显示或其他用途。
  • 确保在自定义过滤器时正确处理 $post_title 参数,以避免导出错误。

📄 原文内容

Filters the post title used for WXR exports.

Parameters

$post_titlestring
Title of the current post.

Source

$title = wxr_cdata( apply_filters( 'the_title_export', $post->post_title ) );

Changelog

Version Description
5.7.0 Introduced.