I'm writing a plugin to allow users to submit fragments of lyrics to my site. I have the plugin working minus one aspect. When entering the lyrics I would like users to be able to select the artist whose lyrics they are from a dropdown. The artists are my custom taxonomy. Here is the function I created for the dropdown:

function suq_get_create_quote_form($suq_quote_author = '', $suq_quote_text = '', $suq_quote_category = 0){
  $out .= '<form id="create_quote_form" method="post" action="">';
    $out .= wp_nonce_field('suq_form_create_quote', 'suq_form_create_quote_submitted');
    $out .= '<label for="suq_quote_author">Who said it?</label><br/>';
    $out .= '<input type="text" id="suq_quote_author" name="suq_quote_author" value="' . $suq_quote_author . '"/><br/>';
    $out .= '<label for="suq_quote_category">Category</label><br/>';  
    $out .= <CALL THE DROPDOWN HERE> . '<br/>';  
    $out .= '<label for="suq_quote_text">Quote</label><br/>';          
    $out .= '<textarea id="suq_quote_text" name="suq_quote_text" />' .   $suq_quote_text . '</textarea><br/><br/>';          
    $out .= '<input type="submit" id="suq_submit" name="suq_submit" value="Submit Quote For Publication">';
  $out .= '</form>';
  return $out;  

The line that reads CALL THE DROPDOWN HERE is where I'm calling the dropdown function, which is this:

function suq_get_quote_categories_dropdown($taxonomy, $output){
    $myterms = get_terms($taxonomy, $args);
    $output ="<select>";
    foreach($myterms as $term){
        $root_url = get_bloginfo('url');
        $term_name =$term->name;
        $link = $root_url.'/'.$term_taxonomy.'/'.$term_slug;
        $output .="<option value='".$link."'>".$term_name."</option>";
    $output .="</select>";
    return $output;

$taxonomy = array('hhie_artists');
    $args = array('orderby'=>'count','hide_empty'=>true);
    echo get_terms_dropdown($taxonomies, $args);

How can I call the dropdown function in my form? Or have I made a mess of the dropdown function?

  • This topic might help. – fuxia May 18 '13 at 14:20
  • There are a couple of PHP problems with the code-- there is a trailing }, for example-- but the basic dropdown function works. If you literally want to know how to call the function then replace <CALL THE DROPDOWN HERE> with suq_get_quote_categories_dropdown('post_tag',array()). If that off-topic pure PHP question isn't it, I don't know what is being asked here. – s_ha_dum May 18 '13 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.