Im want to use Advance Custom Fields module with Gallery add-on


I need to add custom attributes to all images. Like for example paper type, dimensions and so on. All attributes from WordPress core are shown very good. (alt, description, caption) at video from 0:50min (above link)

How can i add to this section other attributes? Any help will be appreciated

closed as off-topic by kaiser Sep 3 '14 at 17:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


You need to use the hooks attachment fields to edit / save to ad and save the fields.

function add_attachment_field_credit( $form_fields, $post ) {
    $form_fields['paper-type'] = array(
        'label' => 'Paper type',
        'input' => 'text',
        'value' => get_post_meta( $post->ID, 'paper_type', true ),
        'helps' => 'Photo paper type'
    return $form_fields;
add_filter( 'attachment_fields_to_edit', 'add_attachment_field_credit', 10, 2 );

function add_attachment_field_credit_save( $post, $attachment ) {
    if( isset( $attachment['paper-type'] ) )
    update_post_meta( $post['ID'], 'paper_type', $attachment['paper-type'] );

    return $post;
add_filter( 'attachment_fields_to_save', 'add_attachment_field_credit_save', 10, 2 );

So this has 2 functions, one adds the field as an array and returns it with the rest, and the second is run on save, checks for the fields and saves the data.

So that will handle getting the data into WordPress. I'm not sure about ACF, You'll need to loop through the gallery and get each image, you should then be able to get the custom fields the same way you got the url and alt from the gallery.

If that doesn't work you cna use get_post_meta with the attachment ID returned from the gallery to get the custom fields you set.

  • I had to use get_field('paper-type', attachment_id to display the value of my custom attribute – Kosmonaft Jan 23 '17 at 9:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.