Untitled

mail@pastecode.io avatar
unknown
php
a year ago
321 B
2
Indexable
Never
function my_get_category( $id ) {
    $term = get_terms( array(
			'taxonomy' => 'product_cat',
			'hide_empty' => false,
			'meta_query' => array(
				array(
					'key'       => '_category_id',
					'value'     => $id,
					'compare'   => '='
				)
			)
		)
	);
	if ( ! empty( $term ) ) {
		return $term[0]->slug;
	}		
}