Table of Contents
Advanced Custom Fields (ACF) allows you to add custom fields to your events. To display ACF field data directly in the event editor, you can use shortcodes. This guide explains how to insert ACF shortcodes into your content without any custom coding.
Create Custom Fields using ACF #
Add value to the field #
Create a shortcode #
Add the code inside your theme’s functions.php file or using any code snippet plugin to enable “custom_acf_field” shortcode in your system.
function display_custom_field_callback($atts) {
global $post;
$field_name = isset($atts['field']) ? $atts['field'] : '';
if ($field_name) {
return get_post_meta($post->ID, $field_name, true);
}
return '';
}
add_shortcode('custom_acf_field', 'display_custom_field_callback');
Use the shortcode [custom_acf_field field=”short_intro”] inside the editor and you will be good to go.