error on update_metadata
-
I have a custom metadata table for taxonomy.
CREATE TABLE IF NOT EXISTS
taxonomymeta
(
meta_id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
taxonomy_id
bigint(20) unsigned NOT NULL DEFAULT ‘0’,
meta_key
varchar(255) DEFAULT NULL,
meta_value
longtext,
PRIMARY KEY (meta_id
),
KEYtaxonomy_id
(taxonomy_id
),
KEYmeta_key
(meta_key
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;My PHP code is as follows. But the data doesn’t get inserted into the table. Why?
<?php add_action('category_add_form_fields', 'category_metabox_add', 10, 1); add_action('category_edit_form_fields', 'category_metabox_edit', 10, 1); add_action('created_category', 'update_category_metadata', 10, 1); add_action('edited_category', 'update_category_metadata', 10, 1); function category_metabox_add($tag) { $output = ' <div class="form-field"> <label for="price">价格</label> <input name="price" type="number"> </div> '; echo $output; } function category_metabox_edit($tag) { $output = ' <tr class="form-field"> <th scope="row" valign="top"> <label for="price">Pricing</label> </th> <td> <input name="price" type="number" value="' . get_metadata("taxonomy", $tag->term_id, "price", true) . '"> </td> </tr> '; echo $output; } function update_category_metadata($term_id) { update_metadata("taxonomy", $term_id, "pricing", $_POST['pricing']); } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘error on update_metadata’ is closed to new replies.