ACF – Show custom image description field in frontend gallery

  • Unknown's avatar

    Hello, everyone,

    I created additional custom fields with the ACF plugin to assign prices and dimensions to my images. In the backend album area when uploading images, these additional fields are also displayed correctly. However, I can’t see them in the frontend.

    I tried customizing the gallery php page. The standard fields (title, description etc.) are – if I understand correctly – defined here:

    		<?php if( $foto_gallery_images){
    			foreach( $foto_gallery_images as $foto_image ):
    			$attachment_id = $foto_image['ID'];
    			$foto_name = $foto_image['title'];
    			$foto_caption = $foto_image['caption'];
    			$foto_image_meta = wp_get_attachment_metadata( $attachment_id );
    			$foto_image_deep_meta = $foto_image_meta['image_meta'];
    			/*metadata*/
    			$foto_image_focal_length = $foto_image_deep_meta['focal_length'];
    			$foto_image_aperture = $foto_image_deep_meta['aperture'];
    			$foto_image_shutter_speed = $foto_image_deep_meta['shutter_speed'];
    			$foto_svggrid_img = aq_resize($foto_image['url'],  475 , 825, true);
    		?>

    and are shown in frontend with this code:
    <h2><?php echo sanitize_text_field( $foto_name ); ?></h2>

    Based on this, I first defined my custom field with the ID “prices”:

    			.....
    $attachment_id = $foto_image['ID'];
    $foto_price = $foto_image['price'];
    ....

    However, when I try to display the “$foto_price”, it just doesn’t show anything.
    Can someone explain to me what I’m doing wrong?

    Best regards
    TB

  • Hi there,

    The best place to get help with that is to post in the plugin’s official forum:

    https://wordpress.org/support/plugin/advanced-custom-fields/

    The forum you have posted is for the WordPress.com hosting platform, which is different than the WordPress software that your site is using. You can learn more about these differences here:

    WordPress.com vs. WordPress.org

  • Unknown's avatar

    thank you, i will open a new thread in the plugin’s forum

  • The topic ‘ACF – Show custom image description field in frontend gallery’ is closed to new replies.