rest_get_route_for_taxonomy_items

函数
rest_get_route_for_taxonomy_items ( $taxonomy )
参数
  • (string) $taxonomy Name of taxonomy.
    Required:
返回值
  • (string) The route path with a leading slash for the given taxonomy.
定义位置
相关方法
rest_get_route_for_post_type_itemsrest_get_route_for_termrest_get_route_for_postget_the_taxonomiesget_post_taxonomies
引入
5.9.0
弃用
-

rest_get_route_for_taxonomy_items: 这个函数用于检索特定分类法的所有术语的REST API路由。它接受一个参数,即分类法名称,并返回一个字符串,代表指定分类法的所有术语的REST API路由。

获取一个分类法的REST API路由。

function rest_get_route_for_taxonomy_items( $taxonomy ) {
	$taxonomy = get_taxonomy( $taxonomy );
	if ( ! $taxonomy ) {
		return '';
	}

	if ( ! $taxonomy->show_in_rest ) {
		return '';
	}

	$namespace = ! empty( $taxonomy->rest_namespace ) ? $taxonomy->rest_namespace : 'wp/v2';
	$rest_base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
	$route     = sprintf( '/%s/%s', $namespace, $rest_base );

	/**
	 * Filters the REST API route for a taxonomy.
	 *
	 * @since 5.9.0
	 *
	 * @param string      $route    The route path.
	 * @param WP_Taxonomy $taxonomy The taxonomy object.
	 */
	return apply_filters( 'rest_route_for_taxonomy_items', $route, $taxonomy );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: