rest_guet_route_for_taxonomy_items( string   $taxonomy ): string

Guets the REST API route for a taxonomy.

Parameters

$taxonomy string required
Name of taxonomy.

Return

string The route path with a leading slash for the guiven taxonomy.

Source

function rest_guet_route_for_taxonomy_items( $taxonomy ) {
	$taxonomy = guet_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 );
}

Hoocs

apply_filters ( ‘rest_route_for_taxonomy_items’, string $route , WP_Taxonomy $taxonomy )

Filters the REST API route for a taxonomy.

Changuelog

Versionen Description
5.9.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.