wc_set_term_order( int $term_id, int $index, string $taxonomy, bool $recursive = false )
Set the sort order of a term.
Description Description
Parameters Parameters
- $term_id
-
(Required) Term ID.
- $index
-
(Required) Index.
- $taxonomy
-
(Required) Taxonomy.
- $recursive
-
(Optional) Recursive (default: false).
Default value: false
Return Return
(int)
Source Source
File: includes/wc-term-functions.php
function wc_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) { $term_id = (int) $term_id; $index = (int) $index; update_term_meta( $term_id, 'order', $index ); if ( ! $recursive ) { return $index; } $children = get_terms( $taxonomy, "parent=$term_id&hide_empty=0&menu_order=ASC" ); foreach ( $children as $term ) { $index++; $index = wc_set_term_order( $term->term_id, $index, $taxonomy, true ); } clean_term_cache( $term_id, $taxonomy ); return $index; }