• andvines99

    (@andvines99)


    Are there shortcode that can be used like ACF had [acf field=”org_address_1″]?

    I have searched and found nothing about SCF and shortcode.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Unfortunately not, but you can create your own like that :

    function display_scf_field($atts) {
    $atts = shortcode_atts(array( 'field' => '', 'post_id' => get_the_ID(), ), $atts, 'scf');
    if (!empty($atts['field'])) {
    $value = get_field($atts['field'], $atts['post_id']);
    return $value ? esc_html($value) : '';
    }
    return '';
    }
    add_shortcode('scf', 'display_scf_field');

    And use the shortcode this way :
    [scf field="org_address_1"]

    j.hoffmann

    (@jhoffmann)

    The acf shortcode has not been removed, you can still use it with this plugin. Just remember that the shortcode needs to be enabled (it has been set to be disabled by default since ACF 6.3).

    function enable_acf_shortcode() {
    acf_update_setting( 'enable_shortcode', true );
    }
    add_action( 'acf/init', 'enable_acf_shortcode' );

    I added this function under “Code Snippets” and it crashed the page. It’s possible I didn’t add it correctly – I copy-and-pasted the entire code section, and put it under PHP Snippets.

    For other with this issue: I was hoping to get the custom fields into the template, but can’t yet find a way that works. I tried metabox blocks in Gutenberg, and it worked for text but not for other formats.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.