wp_sitemaps_posts_pre_max_num_pages
云策文档标注
概述
wp_sitemaps_posts_pre_max_num_pages 是一个 WordPress 过滤器,用于在生成站点地图前修改文章类型的最大页数。传递非空值可以短路生成过程,直接返回该值。
关键要点
- 这是一个过滤器,钩子名为 wp_sitemaps_posts_pre_max_num_pages。
- 用于控制文章类型在站点地图中的最大页数,默认值为 null。
- 传递非空值(如整数)可以跳过默认生成逻辑,直接返回该值。
- 参数包括 $max_num_pages(最大页数,int|null 类型)和 $post_type(文章类型名称,string 类型)。
- 在 WP_Sitemaps_Posts::get_max_num_pages() 方法中使用,位于 wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php 文件中。
- 从 WordPress 5.5.0 版本开始引入。
原文内容
Filters the max number of pages before it is generated.
Description
Passing a non-null value will short-circuit the generation, returning that value instead.
Parameters
$max_num_pagesint|null-
The maximum number of pages. Default null.
$post_typestring-
Post type name.
Source
$max_num_pages = apply_filters( 'wp_sitemaps_posts_pre_max_num_pages', null, $post_type );
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |