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.

enter image description here I want to ask that is there a way display all my custom taxonomies in a drop down menu with checkboxes so when the user check any taxonomy it will be slected and when the user click the submit button .the new post will be created with selected custom taxonomy. i know how to insert it in new post but i WANT TO KNOW ABOUT THE DROPDOWN WITH CHECKBOXES IN THE RED BOX

share|improve this question

1 Answer 1

up vote 1 down vote accepted

To list the options for a custom taxonomy you need to query the taxonomy terms. To do that you use get_terms() http://codex.wordpress.org/Function_Reference/get_terms

// We are assuming color is the name of the taxonomy
$colors = get_terms( 'color', array(
    'orderby'    => 'name',
    'hide_empty' => 0
));

// Now loop through the colors and spit out the checkbox
// with the name of the color as well as the value of the term_id

foreach($colors as $color){ 
....

On the server side for handling the submission (once you get the form correct) you can use wp_set_post_terms() http://codex.wordpress.org/Function_Reference/wp_set_post_terms

share|improve this answer
    
thanks that help me alot –  FAWAZ Nov 29 '12 at 10:31
    
but how can i use wp_set_post_terms() –  FAWAZ Nov 29 '12 at 11:37
1  
wp_insert_post returns the post_id which you pass in to wp_set_terms. You also need to pass in the taxonomy name (i.e. color) as well as the term_id's –  Rezen Nov 29 '12 at 22:41

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.