Can I add the term_order field to the terms edit page? I need a text field, not a sorting plugin.



1 Answer 1


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' );

        <th scope="row"><label for="description">Сортировка</label></th>
        <td><input type="text" name="term_order" value="<?php echo $term_order->term_order; ?>"></td>


// 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.