Support » Plugins » Additional field on Custom Post Type’s Taxonomy

  • Complicated to explain, hang in here.

    I’ve created a Custom Post Type. That Custom Post Type has a taxonomy I created (the “tags” kind). On the “Edit” page in the WordPress UI for a single tag in that taxonomy, I want to be able to add additional fields that users can enter in (and display them on the template page).

    Thoughts on how I would go about doing this? Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’ve now figured out how to add a field to ALL tags, including the taxonomy I created. But how do I make it only apply to a single taxonomy associated with a single Custom Post Type?

    Here’s the code I’ve got so far in functions.php:

    add_action ( 'edit_tag_form_fields', 'your_input_box');
    function your_input_box($tag) {
    	// Get all themes - the hide_empty argument enables you to get all the terms in your 'theme' taxonomy even the empty ones
    	$themes = get_terms('theme', 'hide_empty=0'); 
    <tr class="form-field">
    	<th scope="row" valign="top"><label for="category_theme"><?php _e('Additional Tag Field') ?></label></th>
        <select name='category_theme' id='category_theme'>
    	<option class='theme-option' value='one'>One</option>

    Hmm… is it maybe possible to do this with an If statement?

    Please. Anyone. I’m begging. How do I get it to ONLY apply to this single taxonomy on this single Post Type?

    I’ve now discovered edit_{$taxonomy}_{$field}

    But I can’t figure out how to implement it. Please help?$taxonomy%7D_%7B$field%7D

    Is this even the right tag? Anyone?

    instead of using get_terms() which retrieves ALL terms, use this instead:

    $theme = get_the_terms($post->ID, ‘theme’);

    $theme is of type Array()

    in order to get the value, use this:

    echo $theme[0]->name;

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Additional field on Custom Post Type’s Taxonomy’ is closed to new replies.