钩子文档

wp_sitemaps_taxonomies_pre_url_list

💡 云策文档标注

概述

wp_sitemaps_taxonomies_pre_url_list 是一个 WordPress 过滤器,用于在生成分类法站点地图 URL 列表之前进行干预。开发者可以通过此 Hook 修改或替换 URL 列表,实现自定义逻辑。

关键要点

  • 过滤器在生成分类法站点地图 URL 列表前触发,允许开发者修改或替换列表。
  • 返回非 null 值将短路默认生成过程,直接使用返回的值。
  • 参数包括 $url_list(URL 列表,默认 null)、$taxonomy(分类法名称)和 $page_num(页码)。
  • 在 WordPress 5.5.0 版本中引入。

代码示例

$url_list = apply_filters(
    'wp_sitemaps_taxonomies_pre_url_list',
    null,
    $taxonomy,
    $page_num
);

注意事项

  • 返回非 null 值会跳过默认的 URL 列表生成,需确保返回的数据格式正确。
  • 此过滤器主要用于高级定制,如过滤特定分类法或添加自定义 URL。

📄 原文内容

Filters the taxonomies URL list before it is generated.

Description

Returning a non-null value will effectively short-circuit the generation, returning that value instead.

Parameters

$url_listarray[]|null
The URL list. Default null.
$taxonomystring
Taxonomy name.
$page_numint
Page of results.

Source

$url_list = apply_filters(
	'wp_sitemaps_taxonomies_pre_url_list',
	null,
	$taxonomy,
	$page_num
);

Changelog

Version Description
5.5.0 Introduced.