Link

The Link field type (e.g. ACF Link field) allows a link to be selected or defined (url, title, target) by using the native WordPress link popup.

How to use it

Select the Link field from the Field list. You can add a label as a prefix and a Link Label to replace the default label.

Use a Relational field to 'link' two Custom Post Types (CPT) together. Combine it with a Meta Filter (Pro) to display related content.

You can wrap any image into the link. This well-known technique provides a visual representation, allowing readers to click on the image to open a specified URL.

Make sure both image and link fields are added to the target View, and amend the template to put the img tag inside the a tag, as shown below:

{% if link.value and image.value %}
    <a target="{{ link.target }}"
       href="{{ link.value }}">
        <img src="{{ image.value }}" width="{{ image.width }}" height="{{ image.height }}" alt="{{ image.alt }}" decoding="{{ image.decoding }}" loading="{{ image.loading }}" srcset="{{ image.srcset }}" sizes="{{ image.sizes }}">
    </a>
{% endif %}

On-page link content preview

Whether the link field points out on the external or internal URL, you can display it directly on the page using the <iframe> element:

<iframe src="{{ link.value }}" width="100%" height="600px"></iframe>

FAQs

Last updated