Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » Using CPT-onomies in a form

  • Resolved Sogwap

    (@sogwap)


    I want to use CPT-onomies within a custom form like this:

    <form name=”frm” action=”addalbum.php” method=”post”>
    Artist: <value=”<?=$artist?>” type=”text” name=”artist” size=”40″>
    Album: <input style=”” value=”<?=$album?>” type=”text” name=”album” size=”40″>
    Year: <input id=”MyDate” value=”<?=$year?>” type=”text” name=”year” size=”60″>
    <input style=”” class=”submit-button” type=”submit” value=” SUBMIT “>
    </form>

    How would I go about replacing Artist input field with a drop down of Artist CPT-onomies?

    http://wordpress.org/extend/plugins/cpt-onomies/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rachel Carden

    (@bamadesigner)

    wp_dropdown_categories() is a neat WordPress function that allows you to make dropdowns of taxonomies and it works with CPT-onomies. I actually use it in the admin to print the dropdown filter on the “Edit Posts” screen.

    Here is an example but, for more information, check out wp_dropdown_categories() in the codex.

    $dropdown_options = array(
       'orderby' => 'name',
       'name' => 'artist',
       'taxonomy' => 'artist',
       'selected' => $artist,
       );
    wp_dropdown_categories( $dropdown_options );

    Hope this helps!

    Hi Rachel,

    Thank you for the quick response, much appreciated!
    This seems to be exactly the code I am looking for.

    I had to add the following to the array to show all items. Otherwise it was showing an incomplete list. I added a new artist to my CPT but the new artist didn’t show in my CPT-onomy list up until it was actually used as a taxonomy.
    ‘hide_empty’ => 0,

    Plugin Author Rachel Carden

    (@bamadesigner)

    Ah. I forgot about ‘hide_empty’. Glad you figured it out!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using CPT-onomies in a form’ is closed to new replies.