目前,术语数据库有四列。term_id
name
slug
term_group
. 我想添加另一个名为menu_order
.
我该怎么做?
我想要的结果是能够订购我的自定义条款。
如果有人知道更好的方法,请告诉我。到目前为止,我已经有了设置输入框的代码。我只是需要帮助,试着用get_terms()
作用
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
}
}