How to Fix ACF/SCF Shortcode Empty Output

Category: Guides, WordPress
Last modified on

Introduction

Developers and website administrators often encounter situations where the Advanced Custom Fields (ACF) or Secure Custom Fields (SCF) shortcode returns empty output when attempting to display field values. This article outlines common causes and solutions for this issue.

Enable the Shortcode

First, verify that the ACF/SCF shortcode feature is enabled. Starting with ACF version 6.3, shortcodes are disabled by default for security reasons. You can check the current status by navigating to: Tools → Site Health → Info → ACF/SCF and locating the Shortcode Enabled parameter.

To enable shortcode support, add the following code to your theme’s functions.php file:

// Enables ACF/SCF shortcode. add_action( 'acf/init', function () { acf_update_setting( 'enable_shortcode', true ); });

Grant Access

Beginning with ACF 6.3, you must explicitly grant permission for field values to be accessible via shortcodes. Follow these steps:

  1. Edit your field group
  2. Select the field you want to display via shortcode
  3. Click Edit
  4. Navigate to the Presentation tab
  5. Enable the Allow Access to Value in Editor UI option

After implementing these changes, the shortcode will properly display the field value instead of returning empty output.

Options Fields

When working with fields from the options page, you must:

  1. Grant access permissions as described above
  2. Include the post_id attribute with value options in your shortcode:
[acf field="field_name" post_id="options"]

This instructs the shortcode to look for the field value in the options storage rather than the current post.

Shortcode Override

If you’ve verified all permissions and settings but still experience issues, you can implement a manual shortcode override. Use this solution cautiously as it bypasses built-in security measures.

Add this code to your functions.php file:

// Rewrites ACF/SCF shortcode. add_shortcode( 'acf', function ( $atts ) { $value = apply_filters( 'acf/format_value', get_field( $atts[ 'field' ], $atts[ 'post_id' ] ) ); return $value; });

Additional Tips

  1. Clear all caching layers (object cache, page cache, browser cache)
  2. Verify field values exist in the database
  3. Check for JavaScript errors in browser console
  4. Test with default WordPress theme to rule out theme conflicts
  5. Ensure you’re using the correct field name (case-sensitive)

For persistent issues, consider consulting the official ACF documentation or reaching out to their support team.

Related Posts

by the same categories