WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Metadata
Saving the value of a selected option as taxonomy's term metadata (1 post)

  1. VOST
    Member
    Posted 2 months ago #

    Hello,
    using the Taxonomy Metadata plugin (http://wordpress.org/plugins/taxonomy-metadata/) I have set up inputs for my custom taxonomies' terms and can save the information associated with those inputs.
    But now I am trying to set up a select drop-down list with a Yes or No choice but cannot save the selection made.

    Here is my select drop-down list code:

    <tr class="form-field">
    	<th scope="row" valign="top"><label for="setIndividual"><?php _e('Are the books sold individually?'); ?></label></th>
    	<td>
    		<select name="setIndividual" id="setIndividual">
    			<option value="No" <?php selected( $setIndividual, 'No' ); ?> >No</option>
    			<option value="Yes" <?php selected( $setIndividual, 'Yes' ); ?> >Yes</option>
                	</select>
                	<p class="description"><?php _e('No is the default value'); ?></p>
            </td>
    </tr>

    And here is the code I use to save the data associated with the corresponding variables ($setNumber and $setIndividual in that example) but it doesn't save the value of the selected drop-drown list option:

    function save_taxonomy_metadata( $term_id ) {
    	if ( isset($_POST['setNumber']) )
    		update_term_meta( $term_id, 'setNumber', esc_attr($_POST['setNumber']) );
    	if ( isset($_POST['setIndividual']) )
    		update_term_meta( $term_id, 'setIndividual', esc_attr($_POST['SetIndividual']) );
    }

    When with inputs, like with $setNumber, the data is saved though. Here is the code for an input:

    <tr class="form-field">
    	<th scope="row" valign="top">
    		<label for="setNumber"><?php _e('How many items in the set?'); ?></label>
    	</th>
    	<td>
    		<input name="setNumber" id="setNumber" type="text" value="<?php echo get_term_meta($tag->term_id, 'setNumber', true); ?>" />
    		<p class="description"><?php _e('For example: Numbers 1 to 10 or The three volumes'); ?></p>
    	</td>
    </tr>

    What matters in this piece of code, I suppose, is the following:

    get_term_meta($tag->term_id, 'setNumber', true);

    And I try to get something similar with my select drop-down list.

    Thank you

    https://wordpress.org/plugins/taxonomy-metadata/

Reply

You must log in to post.

About this Plugin

About this Topic