钩子文档

wp_sitemaps_post_types

💡 云策文档标注

概述

wp_sitemaps_post_types 是一个 WordPress 过滤器,用于修改站点地图中可用的文章对象子类型列表。它允许开发者自定义哪些文章类型被包含在站点地图中。

关键要点

  • 这是一个过滤器,用于过滤站点地图中的文章对象子类型列表。
  • 参数 $post_types 是一个数组,包含按名称索引的已注册文章类型对象。
  • 在 WP_Sitemaps_Posts::get_object_subtypes() 中使用,返回公共文章类型,排除 nav_items 等类型。
  • 从 WordPress 5.5.0 版本开始引入。

代码示例

apply_filters( 'wp_sitemaps_post_types', $post_types );

📄 原文内容

Filters the list of post object sub types available within the sitemap.

Parameters

$post_typesWP_Post_Type[]
Array of registered post type objects keyed by their name.

Source

return apply_filters( 'wp_sitemaps_post_types', $post_types );

Changelog

Version Description
5.5.0 Introduced.