Shortcode

Last updated Jan 15, 2024

Overview

Shortcodes can be used within a WYGIWYG to display another field’s value. To learn more about shortcodes, click here.

For security, we recommend disabling the ACF shortcode if you are not using it.

Usage

Place the shortcode marker with the desired field within your wysiwyg content. This shortcode runs the same as the the_field() function.

[acf field="field_name" post_id="123"]

Example

This is a story about a boy named [acf field="name"]. He is [acf field="age"] years old.

Limitations

  • Only works for simple text based values

Disabling the Shortcode

The ACF shortcode allows access to any field on any post type. This means any user who has permission to publish posts on your site can view any ACF data if they know the field name or key. For this reason, we recommend you disable the shortcode if your site is not using it. You can use the following setting to disable it:

add_action( 'acf/init', 'set_acf_settings' );
function set_acf_settings() {
    acf_update_setting( 'enable_shortcode', false );
}