URL

Last updated Sep 26, 2023

Description

The URL field is a text input specifically designed for storing web addresses.

Screenshots

Creating a URL field in the UI.

Creating a URL field in the UI.

The Presentation tab of the Url field allows you to provide instructions to content editors, show placeholder text, and define wrapper attributes.

The Presentation tab of the URL field allows you to provide instructions to content editors, show placeholder text, and define wrapper attributes.

How the field is displayed to content editors in WP Admin.

How the field is displayed to content editors in WP Admin.

Settings

  • Default Value
    The default value shown when creating a new post.

  • Required
    Found on the Validation tab, this requires a valid URL be provided as the input and prevents the field from accepting empty values. Defaults to off.

  • Instructions
    Shows instructions when submitting data.

  • Placeholder Text
    Appears within input when no value exists.

Template usage

Display value

This example demonstrates how to use a URL field named “sales_url” within an anchor tag. We don’t recommend outputting any ACF value without any sort of protection or escaping.

<a href="<?php echo esc_attr( get_field('sales_url') ); ?>"><?php echo esc_attr( get_field('sales_url') ); ?></a>