WordPress.org

Ready to get started?Download WordPress

Forums

CPT-onomies: Using Custom Post Types as Taxonomies
[resolved] Using CPT-onomies in a form (4 posts)

  1. Sogwap
    Member
    Posted 1 year ago #

    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/

  2. Rachel Carden
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  3. Sogwap
    Member
    Posted 1 year ago #

    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,

  4. Rachel Carden
    Member
    Plugin Author

    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic