Support » Fixing WordPress » 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),
    KEY taxonomy_id (taxonomy_id),
    KEY meta_key (meta_key)

    My PHP code is as follows. But the data doesn’t get inserted into the table. Why?

    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">
    	echo $output;
    function category_metabox_edit($tag) {
    	$output = '
    	<tr class="form-field">
    		<th scope="row" valign="top">
    			<label for="price">Pricing</label>
    			<input name="price" type="number" value="' . get_metadata("taxonomy", $tag->term_id, "price", true) . '">
    	echo $output;
    function update_category_metadata($term_id) {
    	update_metadata("taxonomy", $term_id, "pricing", $_POST['pricing']);

Viewing 1 replies (of 1 total)
  • Same here it didn’t save even I applied filter and action after add function, would be great is WP provide more sample and documentation, don’t have time to try and dig in myself 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘error on update_metadata’ is closed to new replies.