Currently the Term Database has four columns. term_id name slug term_group. I would like to add another column called menu_order.
How can i do this?
The outcome i want is to be able to order my custom terms.
If anyone knows of a beter way to do this please let me know. So far i already have code that sets up the input box. I just need help trying to order it using the get_terms() function.
add_action ( 'section_edit_form_fields', 'create_section_menu_order');
function create_section_menu_order( $tag )
{
//check for existing featured ID
$section_order = get_option( 'section_menu_order' );
$order_id = '';
if ( is_array( $section_order ) && array_key_exists( $tag->term_id, $section_order ) ) {
$order_id = $section_order[$tag->term_id];
}
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="section_menu_order"><?php _e('Order') ?></label></th>
<td>
<input type="text" name="section_menu_order" id="section_menu_order" size="10" style="width:60px;" maxlength="6" value="<?php echo $order_id; ?>"><br />
<span class="description">The order your Sections will show. (Numeric digits only)</span>
</td>
</tr>
<?php
}
add_action ( 'edited_section', 'save_section_menu_order');
function save_section_menu_order( $term_id )
{
if ( isset( $_POST['section_menu_order'] ) && is_numeric($term_id))
{
$section_menu_order = get_option( 'section_menu_order' ); //load existing category featured option
$section_menu_order[$term_id] = intval( $_POST['section_menu_order'] ); //set featured post ID to proper category ID in options array
update_option( 'section_menu_order', $section_menu_order ); //save the option array
}
}