Support

Account

Home Forums Add-ons Gallery Field Add custom link to ACF Gallery images

Solving

Add custom link to ACF Gallery images

  • Hi, I’m searching to add a custom link on my ACF gallery images and I can’t find the solution. I found this plugin, WP Gallery Custom Links, but I don’t know how to add their code in my template:
    $custom_url = get_post_meta( $attachment_id, ‘_gallery_link_url’, true );

    Does someone have an idea of how can I do without plugin or with this one?

    Thank you by advance, best

    Pierre

  • You cannot add links to the gallery. You could create a field groups that is added to “attachments” and add the links when editing the image. Then when looping through the gallery you can use the attachment ID to get this other custom field and do something with it.

  • Ok, thank you, but I don’t see how can I write all this in my code. Do you have an article about that or a code exemple, maybe?

    Thanks a lot

  • No, I don’t think there is an artical specifically about this.

    You get fields from the attachment the same way you get fields from a post, you just need to supply the attachment ID

    
    get_field('field_name', $attachment_id);
    
  • Ok, thank you for your answer!

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

The topic ‘Add custom link to ACF Gallery images’ is closed to new replies.