WordPress.org

Ready to get started?Download WordPress

Forums

Custom taxonomy in 3.5 media library (3 posts)

  1. stvwlf
    Member
    Posted 1 year ago #

    I have a hierarchical custom taxonomy defined on the attachment post type. The Media > Library option correctly displays the taxonomy terms in a hierarchical category-like metabox.

    When I open an image for editing in the new Insert Media overlay, the hierarchical custom taxonomy is displayed with a tag-like single entry field and no list of the pre-defined taxonomy terms, instead of with the desired category-like list of terms with checkboxes.

    Is this intentional or a bug? Is there a workaround?
    thank you

  2. sinusite
    Member
    Posted 1 year ago #

    yeah it seems 'this part' is not finished :)

    Well you can do that (but it's baaaad and harcoding) :
    go wp-include/media.php line 1380 insert something like that:

    // make a select if is a taxonomy
    		if ($field['taxonomy'] == 1){
    			$terms = get_terms('YOUR_TAXONOMY', 'orderby=name&hide_empty=0');
    			$item .= "<select class='select-".$term->slug."' id='$id_attr' name='$name' $readonly required>";
    			$selected = 'selected';
    			$item .= '<option value="" '. $selected.'>Choose...</strong></option>';
        		foreach ($terms as $term) {
        			$selected = ($term->slug == $field['value'] ) ? 'selected':'';
        			$item .= '<option value="'. $term->slug .'" '. $selected.'>' . $term->name . '</option>';
        		}
    			$item .= "</select>";

    But the cleanest way is to change the text field with jQuery in your theme or plugin - because here you will loose code after an update of WP...

  3. stvwlf
    Member
    Posted 1 year ago #

    Hi

    Thanks for your response. Actually I found a plugin
    http://wordpress.org/extend/plugins/media-categories-2/
    that accomplishes this.

Topic Closed

This topic has been closed to new replies.

About this Topic