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

get_term_slug


Description Description

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


Top ↑

Parameters Parameters

$taxonomy_name

(string) (Required) A taxonomy name

$post_id

(int) (Required) A Post ID


Top ↑

Return Return

(string) A term slug


Top ↑

Source Source

File: includes/class-taxonomies.php

	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 '';
	}