Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I cannot figure out how to get the taxonomy term name if I have the taxonomy term's ID.

This is my current code

// create a dropdown menu of the quantity taxonomy 
wp_dropdown_categories( 
    array('taxonomy' => 'quantity_category', 'name' => 'productQuantity', 'hide_empty' => 0)
); 

$quantityTerms = $_POST['productQuantity'];
$quantityTax   = 'quantity_category';

The value of $quantityTerms is not the "name" of the quantity but the ID of the quantity category. When it sets the object terms, it creates a new category called "ID#" and not inserting it into the category by name.

wp_set_object_terms( $post_id, $quantityTerms, $quantityTax, $append );
share|improve this question
3  
@JonFury, many of your questions demonstrate a complete lack of research effort - you could have answered this question for yourself by typing it's title into Google, not to mention that's it's answered in numerous other on-site questions that you would have seen had you searched WPSE. No one wants to waste their time answering questions that have been answered a hundred times before already. Please use a search engine, the WPSE search, and the WordPress codex before slapping questions on WPSE. Our community is not a search engine. –  boscho Jan 1 at 22:17

1 Answer 1

The function get_term_by() would allow you to get the taxonomy term name from the id.

$quantityTermObject = get_term_by( 'id', absint( $quantityTerms ), 'quantity_category' );
$quantityTermName = $quantityTermObject->name;
share|improve this answer
    
Thanks!@##!!!!! –  Jon Furry Nov 27 '13 at 4:42
5  
Please accept the answer if it worked for you @JonFurry. –  Rachel Baker Nov 27 '13 at 13:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.