WC_Data_Store_WP::get_term_ids()
Get and store terms from a taxonomy.
Method of the class: WC_Data_Store_WP{}
No Hooks.
Return
Array
. of terms
Usage
// protected - for code of main (parent) or child class $result = $this->get_term_ids( $object, $taxonomy );
- $object(WC_Data|int) (required)
- WC_Data object or object ID.
- $taxonomy(string) (required)
- Taxonomy name e.g. product_cat.
Changelog
Since 3.0.0 | Introduced. |
WC_Data_Store_WP::get_term_ids() WC Data Store WP::get term ids code WC 9.4.2
protected function get_term_ids( $object, $taxonomy ) { if ( is_numeric( $object ) ) { $object_id = $object; } else { $object_id = $object->get_id(); } $terms = get_the_terms( $object_id, $taxonomy ); if ( false === $terms || is_wp_error( $terms ) ) { return array(); } return wp_list_pluck( $terms, 'term_id' ); }