WordPress.org

Forums

Advanced Custom Fields
SOLVED Image URL and link on thumbnail (1 post)

  1. mapero
    Member
    Posted 10 months ago #

    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/

Reply

You must log in to post.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic