Inventory_Presser_Taxonomies::get_term_slug( string $taxonomy_name, int $post_id )

Given taxonomy and post ID, find the term with a relationship to the post and return its slug.


Parameters

$taxonomy_name

(string) (Required) A taxonomy name

$post_id

(int) (Required) A Post ID


Return

(string) A term slug


Source

File: includes/class-taxonomies.php

	protected static function get_term_slug( $taxonomy_name, $post_id ) {
		$terms = wp_get_object_terms(
			$post_id,
			$taxonomy_name,
			array(
				'orderby' => 'term_id',
				'order'   => 'ASC',
			)
		);
		if ( ! is_wp_error( $terms ) && isset( $terms[0] ) && isset( $terms[0]->name ) ) {
			return $terms[0]->slug;
		}
		return '';
	}