Support » Plugin: ACF Photo Gallery Field » Additional Fields not working in frontend

  • Resolved flowr420

    (@flowr420)


    Hey! First of all thanks for the awesome work!

    I have a problem with the additional fields. It works fine in the backend and I see the updated values for each image there. If I want to pull the fields in the fronend it does not work. Do you have an idea what I’m doing wrong?

    functions.php

    
    //Create extra fields for ACF Photo Gallery Field
    function my_extra_gallery_fields( $args, $attachment_id, $field ){
        // Model Insta Link Field for Gallery
        $args['insta_link'] = array(
            'type'  => 'text',
            'label' => 'Model Insta Link',
            'name'  => 'insta-link',
            'value' => get_field($field . '_insta_link', $attachment_id)
        );
        // Model Insta Name Field for Gallery
        $args['insta_name'] = array(
            'type'  => 'text',
            'label' => 'Model Insta Name',
            'name'  => 'insta_name',
            'value' => get_field($field . '_insta_name', $attachment_id)
        );
    
        return $args;
    }
    add_filter( 'acf_photo_gallery_image_fields', 'my_extra_gallery_fields', 10, 3 );
    

    Frontend

    
    $id = $image['id'];
    $title = $image['title'];
    $caption= $image['caption'];
    $instaLink = get_field('photo_gallery_insta_link', $id); // not working
    $instaName = get_field('photo_gallery_insta_name', $id); // not working
    $fullImageUrl = $image['full_image_url'];
    
    var_dump($instaLink); // <-- gives NULL
    var_dump($instaName); // <-- gives NULL
    

    Thanks!

    • This topic was modified 6 months, 3 weeks ago by flowr420.
    • This topic was modified 6 months, 3 weeks ago by flowr420.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Navneil Naicker

    (@navzme)

    Hi,

    What’s the first parameter you are passing to the function acf_photo_gallery('WHAT YOU WROTE HERE?', $post->ID)

    Hi!

    Tha’d be ‘images’. I’ve realized that this was the problem and I had to do get_field('images_insta_name', $id) instead of get_field('photo_gallery_insta_name', $id).

    Unfortunately the $instaLink is not working! Whenever I try to save the link the field just appears blank. Do I need to use url instead of text or something?

    Thanks a lot!

    Plugin Author Navneil Naicker

    (@navzme)

    Hi,

    I guess the problem is over here in this code.

    $args['insta_link'] = array(
            'type'  => 'text',
            'label' => 'Model Insta Link',
            'name'  => 'insta-link', //Change insta-link to insta_link
            'value' => get_field($field . '_insta_link', $attachment_id)
        );

    Change insta-link to insta_link

    Exactely! Sorry for bothering you!

    Thanks a lot!

    Plugin Author Navneil Naicker

    (@navzme)

    No problem.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Additional Fields not working in frontend’ is closed to new replies.