wc_get_product_term_ids() WC 3.0.0
Retrieves product term ids for a taxonomy.
No Hooks.
Return
Array.
Usage
wc_get_product_term_ids( $product_id, $taxonomy );
- $product_id(int) (required)
- Product ID.
- $taxonomy(string) (required)
- Taxonomy slug.
Changelog
Since 3.0.0 | Introduced. |
Code of wc_get_product_term_ids() wc get product term ids WC 5.0.0
function wc_get_product_term_ids( $product_id, $taxonomy ) {
$terms = get_the_terms( $product_id, $taxonomy );
return ( empty( $terms ) || is_wp_error( $terms ) ) ? array() : wp_list_pluck( $terms, 'term_id' );
}