Support » Plugin: Advanced Custom Fields (ACF) » SOLVED Image URL and link on thumbnail

  • Here is mine solution for getting URL from image attachment

    <?php
    $myurl = get_field('custom_filed_name');
    echo wp_get_attachment_url( $myurl ); ?>

    and this is thumb image with hyperlink to image source.

    <a href="<?php
    $myurl = get_field('custom_filed_name');
    echo wp_get_attachment_url( $myurl ); ?>
    ">
    
    <?php
    $image = get_field('custom_filed_name');
    $size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
    
    if( $image ) {
     	echo wp_get_attachment_image( $image, $size );
     }?>
    </a>

    https://wordpress.org/plugins/advanced-custom-fields/

  • The topic ‘SOLVED Image URL and link on thumbnail’ is closed to new replies.