Did it yourself. If someone needs:
// Adding a field to sort on the category edit page
add_action( 'product_cat_edit_form_fields', 'product_cat_edit_category', 5 );
function product_cat_edit_category( $term ) {
$term_order = get_term( $term->term_id, 'product_cat' );
?>
<tr>
<th scope="row"><label for="description">Сортировка</label></th>
<td><input type="text" name="term_order" value="<?php echo $term_order->term_order; ?>"></td>
</tr>
<?php
}
// Update term_order value when saving taxonomy
add_action( 'edit_product_cat', 'product_cat_save', 10, 1 );
function product_cat_save( $term_id ) {
global $wpdb;
if ( isset( $_POST['term_order'] ) ) {
$term_order = $_POST['term_order'];
$wpdb->query('UPDATE '.$wpdb->prefix.'terms SET term_order=".$term_order." WHERE term_id='.$term_id);
wp_redirect( esc_url_raw( get_edit_term_link( $term_id, 'product_cat', 'product' ) ) );
}
} //end function product_cat_save
In add_action, where edit_product_cat
andproduct_cat_edit_form_fields
should be the name of your taxonomy instead of product_cat. in my case, these are the categories of woocommerce products.