钩子文档

get_{$adjacent}_post_excluded_terms

💡 云策文档标注

概述

此过滤器用于在相邻文章查询中排除指定术语ID,动态钩子名称基于相邻类型('next' 或 'previous')。

关键要点

  • 钩子名称动态部分 $adjacent 表示相邻类型,如 get_next_post_excluded_terms 或 get_previous_post_excluded_terms。
  • 参数 $excluded_terms 为整数数组或字符串,用于传递被排除的术语ID,若无则为空字符串。
  • 此过滤器在 get_adjacent_post() 函数中使用,影响相邻文章的检索逻辑。
  • 自 WordPress 4.4.0 版本引入。

代码示例

$excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );

📄 原文内容

Filters the IDs of terms excluded from adjacent post queries.

Description

The dynamic portion of the hook name, $adjacent, refers to the type of adjacency, ‘next’ or ‘previous’.

Possible hook names include:

  • get_next_post_excluded_terms
  • get_previous_post_excluded_terms

Parameters

$excluded_termsint[]|string
Array of excluded term IDs. Empty string if none were provided.

Source

$excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );

Changelog

Version Description
4.4.0 Introduced.