
站长必备技能:浏览器缓存数据怎么清理?
rest_get_route_for_term ( $term )
rest_get_route_for_term: 这个函数用于检索分类法中某个特定术语的REST API路由。它接受两个参数,术语ID和分类法名称,并返回一个代表指定术语的REST API路由的字符串。
获取一个术语的REST API路由。
function rest_get_route_for_term( $term ) { $term = get_term( $term ); if ( ! $term instanceof WP_Term ) { return ''; } $taxonomy_route = rest_get_route_for_taxonomy_items( $term->taxonomy ); if ( ! $taxonomy_route ) { return ''; } $route = sprintf( '%s/%d', $taxonomy_route, $term->term_id ); /** * Filters the REST API route for a term. * * @since 5.5.0 * * @param string $route The route path. * @param WP_Term $term The term object. */ return apply_filters( 'rest_route_for_term', $route, $term ); }