• Resolved HJG

    (@hjg)


    Hi there,

    Im looking for a way to put a shortcode into my ACF custom field [nested_shortcode] and with Advanced Views Framework im using the ACF shortcode to display my [nested_shortcode] – how is this possible? as of now – im just getting the [nested_shortcode] as text.

    Chat GPT has been super unhelpful, maybe you han help me out..

    Question:
    “can i put a shortcode inside a shortcode , in the WordPress plugin “advanced view framework” id like to make an ACF custom field as a shortcode and display it on a post , the custom field will contain a shortcode . but now it only diplays the shotcode as the actual shortcode – how do i fix this?”

    Answer:

    In WordPress, you can nest shortcodes and process them so that the inner shortcode is rendered correctly. The issue you’re experiencing happens because WordPress does not automatically process shortcodes within the output of another shortcode.

    To fix this in the Advanced View Framework or any custom WordPress plugin, you need to ensure that the output of the outer shortcode is passed through the do_shortcode() function. Here’s how you can address this:1. Modify Your Custom Shortcode Callback

    If you are creating a custom shortcode to display an ACF field, update the callback function to process the inner shortcodes. Here’s an example:

    php

    Copy code

    add_shortcode('acf_field_shortcode', function ($atts) { $atts = shortcode_atts([ 'field' => '', 'post_id' => null, ], $atts); // Get the ACF field value $field_value = get_field($atts['field'], $atts['post_id']); // Process shortcodes within the field value return do_shortcode($field_value); });

    With this setup:

    • [acf_field_shortcode field="your_field_name"] will render the ACF field’s value, processing any shortcodes inside it.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WPLake

    (@wplakeorg)

    Hi @hjg

    In short, yes Advanced Views can display the shortcode within an ACF Field.
    When setting up your ACF field, use the WYSIWYG field type, then in Advanced Views, select that field, update or publish your View, and copy the shortcode similar to this e.g. [avf_view name=”nested shortcode” view-id=”6746d09c6654e”] into place.

    Please let me know if this works for you.

    Plugin Author WPLake

    (@wplakeorg)

    We’re closing this ticket as there’s been no reply.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Nested shortcodes possible?’ is closed to new replies.