• WP Migrate
  • WP Offload Media
  • WP Offload SES
  • About
  • Podcast
  • Advanced Custom Fields

  • Documentation
  • PRO
  • Blog
  • Support
  • Account
  • Purchase
  • WP Migrate
  • WP Offload Media
  • WP Offload SES

Link

Documentation Field Types Link

Description

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

Screenshots

A Link field that allows you to enter a new URL or choose an existing link from a list
The Link field interface
List of field settings shown when setting up a Link field
The Link field settings

Changelog

  • Added in version 5.6.0.

Settings

  • Return value
    Specifies the format of the returned data. Choose from Link Array (array of data) or Link URL (string).

Template usage

The Link field will return either an array or string depending on the return value setting. Below are some examples of how you can use this data.

Basic Display (array)

This example demonstrates how to display the selected link when using the Link Array return type.

<?php 
$link = get_field('link');
if( $link ): 
    $link_url = $link['url'];
    $link_title = $link['title'];
    $link_target = $link['target'] ? $link['target'] : '_self';
    ?>
    <a class="button" href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?></a>
<?php endif; ?>

Basic display (string)

This example demonstrates how to display the selected link when using the Link URL return type.

<?php 
$link = get_field('link');
if( $link ): ?>
    <a class="button" href="<?php echo esc_url( $link ); ?>">Continue Reading</a>
<?php endif; ?>

On this page

    In this category

    • Accordion
    • Button Group
    • Checkbox
    • Clone
    • Color Picker
    • Date Picker
    • Date Time Picker
    • Email
    • File
    • Flexible Content
    • Gallery
    • Google Map
    • Group
    • Image
    • Link
    • Number
    • oEmbed
    • Page Link
    • Password
    • Post Object
    • Radio Button
    • Range
    • Relationship
    • Repeater
    • Select
    • Tab
    • Taxonomy
    • Text
    • Text Area
    • Time Picker
    • True / False
    • URL
    • User
    • Wysiwyg Editor

    About

    • PRO
    • Blog
    • Account

    Help

    • Docs
    • FAQs
    • Forums
    • Contact
    • Changelog

    Community

    • WordPress
    • Github
    • Twitter
    • AwesomeACF

    Products

    • WP Migrate
    • WP Offload Media
    • WP Offload SES

    © 2023 Delicious Brains Inc. All rights reserved.

    Privacy Policy | Terms and Conditions

    We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.

    Got it