Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to remove the caption field from non-images attachments' edit page, which should be a simple matter of unset($post['post_excerpt']), but I can't unset a non-existent value...

Looking at the core, this Array being empty should mean that no fields exist on the attachment page, but all the expected fields are there (plus custom ones I've added). I'm completely and utterly baffled.

I've tried extremely high & extremely low priority values in applying the filter, neither of which makes a difference.

Below is a test case showing the empty Array before and the Array with just my custom field after.

function attachment_fields_edit( $form_fields, $post ) {
    print_r( $form_fields ); // Array ( )

    $form_fields['author'] = array(
    'label' => __('Author'),
    'input' => 'text',
    'value' => get_post_meta( $post->ID, "author", true ) );

    print_r( $form_fields );
    /* OUTPUT:
    Array
    (
        [author] => Array
            (
                [label] => Author
                [input] => text
                [value] => Author Name
            )
    )
    */
}
add_filter( 'attachment_fields_to_edit', 'attachment_fields_edit', null, 2 );`

I don't know what to do about this. It makes no sense based on the code I'm looking at. Any help would be appreciated!

PS: Given recent changes to the Media Manager, my working theory is that this may be related in some way to this change...

share|improve this question
    
Yeah, @Dan. I'm running into the same thing. This comment on trac would seem to verify your thoughts about the new media manager working differently. Did you have any luck figuring this one out? –  infamouse Apr 3 '13 at 20:06
    
After investigating the only thing I could figure out was to catch admin_head and admin_footer to forcibly modify the HTML. It's pretty klugey. –  infamouse Apr 3 '13 at 21:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.