Support

Account

Home Forums Front-end Issues Gallery problems (doesn't retrive the gallery field in front-end)

Helping

Gallery problems (doesn't retrive the gallery field in front-end)

  • Good Morning, I have two problems with the gallery custom field. I’ve added a group field with gallery attribute to some page of the site, where a user can upload his/her own gallery, that will retrived on his/her personal page of the website. In the first page, with the function acf_form() the gallery appears, after all the others custom fields, and here is the first problem: how to manage the fields separately? I mean, I want to put the gallery in a different row and customize the aspect of it, not in the same row of the other group field.
    The second problem is: In the front-end page the function get_field() doesn’t retrive anything from the gallery that I uploaded on the first page, here is the code:

    <?php echo get_field('galleria_partner');
     $author_id = get_the_author_meta('ID');
     $author_badge = get_field('author_badge', 'user_'. $author_id );
     $images = get_field('galleria_partner'); var_dump($images);
     $size = 'full'; // (thumbnail, medium, large, full or custom size)
       if( $images ): ?>
          <ul>
          <?php foreach( $images as $image_id ): ?>
          <img />">
           <li>
           <?php echo wp_get_attachment_image( $image_id, $size ); ?>
           </li>
      <?php endforeach; ?>
      </ul>
      <?php endif; ?>

    Can you help me with those problems? Thanks!

  • If the gallery is for a user, you need to change the get_field for the gallery to include the user ID:

    $images = get_field('galleria_partner', 'user_'. $author_id);

    This assumes you have access to $author_id!?

    As for showing info on different rows, that’s just HTML and entirely up to you.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.