Title: Cannot add custom fields
Last modified: August 20, 2016

---

# Cannot add custom fields

 *  Resolved [apakin](https://wordpress.org/support/users/apakin/)
 * (@apakin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/)
 * Hi!
    I’ve installed the plugin and edited the functions.php:
 *     ```
       function my_attachments( $attachments )
       {
         $args = array(
   
           // title of the meta box (string)
           'label'         => 'My Attachments',
   
           // all post types to utilize (string|array)
           'post_type'     => array( 'post', 'page' ),
   
           // allowed file type(s) (array) (image|video|text|audio|application)
           'filetype'      => null,  // no filetype limit
   
           // include a note within the meta box (string)
           'note'          => 'Attach files here!',
   
           // text for 'Attach' button (string)
           'button_text'   => __( 'Attach Files', 'attachments' ),
   
           // text for modal 'Attach' button (string)
           'modal_text'    => __( 'Attach', 'attachments' ),
   
           // fields for this instance (array)
           'fields'        => array(
             array(
               'name'  => 'title',                          // unique field name
               'type'  => 'text',                           // registered field type (field available in 3.0: text)
               'label' => __( 'Title', 'attachments' ),     // label to display
             ),
             array(
               'name'  => 'caption',                        // unique field name
               'type'  => 'text',                           // registered field type (field available in 3.0: text)
               'label' => __( 'Caption', 'attachments' ),   // label to display
             ),
             array(
               'name'  => 'group',                      // unique field name
               'type'  => 'text',                           // registered field type (field available in 3.0: text)
               'label' => __( 'Group', 'attachments' ), // label to display
             ),
           ),
   
         );
   
         $attachments->register( 'my_attachments', $args ); // unique instance name
       }
       ```
   
 * But I still don’t see the “Group” field in “Edit Post”: [screenshot](http://goo.gl/RFqz4)
 * Thank you
 * M
 * [http://wordpress.org/extend/plugins/attachments/](http://wordpress.org/extend/plugins/attachments/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297950)
 * Hi M, you need to add the action as well:
 * `add_action( 'attachments_register', 'my_attachments' );`
 * You can add that below the function you pasted.
 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297951)
 * Also, your screenshot is using the default instance (meta box titled Attachments
   with two fields, one for Title one for Caption) — if you don’t want to use the
   default instance you can disable it and use the one you’re defining in your snippet
   by adding the following to your `wp-config.php`:
 * `define( 'ATTACHMENTS_DEFAULT_INSTANCE', false );`
 *  Thread Starter [apakin](https://wordpress.org/support/users/apakin/)
 * (@apakin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297952)
 * I have this string. Sorry, didn’t write it.
 *     ```
       $attachments->register( 'my_attachments', $args ); // unique instance name
       }
   
       add_action( 'attachments_register', 'my_attachments' );
       ```
   
 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297955)
 * Did you disable the default instance? Your snippet will work as expected, I tested
   locally and it works. Perhaps the meta box is hidden (check your Screen Options
   tab in the upper right of the post edit screen)?
 *  Thread Starter [apakin](https://wordpress.org/support/users/apakin/)
 * (@apakin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297956)
 * Cannot disable right now, I don’t have FTP access.
    But the irony is that it’s
   worked till I upgraded the plugin. OK, thanx for help, I will wait for a man 
   with FTP-password 🙂
 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297957)
 * Which version was it working with? Which version did you upgrade to that broke
   it?
 *  Thread Starter [apakin](https://wordpress.org/support/users/apakin/)
 * (@apakin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297962)
 * From 1.6.2.1 to 3.0.6
 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3297965)
 * I see, okay so yes I’m thinking you’re actually working with the default instance
   instead of the one you’re trying to register. Are there two meta boxes on the
   edit screen?
 *  Thread Starter [apakin](https://wordpress.org/support/users/apakin/)
 * (@apakin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3298012)
 * Sorry, but it still doesn’t work.
    I don’t even know where to look.
 * [Screenshot of Screen Options](http://goo.gl/5P2gj) (I don’t see “meta box” there).
   
   [Screenshot of editor with functions.php](http://goo.gl/KpM8p) (yes, I’ve pressed“
   Update File” button :)) [Screenshot of wp-config.php](http://goo.gl/Hle3U)
 * Attachments 3.0.6, WP 3.4.2
 *  Thread Starter [apakin](https://wordpress.org/support/users/apakin/)
 * (@apakin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3298027)
 * And another one thing: when I opened functions.php and wp-config.php, there wasn’t
   this required blocks of code. How did it work before update? Could plugin update
   delete this strings? If not, I don’t understand, how it was working. Till yesterday
   update another man configured WP with all the plugins 🙁
 * Sorry for my terrible English and yammer, I’m in little panic 🙂
 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3298031)
 * No, the plugin does not touch what you’ve written, it’s worked the same way since
   3.0 launched. These snippets were not part of 1.6 and earlier. If you can pass
   along WordPress login information to [jonathan@mondaybynoon.com](https://wordpress.org/support/topic/cannot-add-custom-fields/jonathan@mondaybynoon.com?output_format=md)
   I’d be more than happy to figure out what’s missing.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Cannot add custom fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/attachments_fafafa.svg)
 * [Attachments](https://wordpress.org/plugins/attachments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/attachments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/attachments/)
 * [Active Topics](https://wordpress.org/support/plugin/attachments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/attachments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/attachments/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/cannot-add-custom-fields/#post-3298031)
 * Status: resolved