$atts['form_id']
contains the form_id
that was passed with the Shortcode. You are searching for this form_id
among the data that is held in the forms
field.
$forms
is an array, and each item in the array is another array with your two keys: form_id
and form_markup
.
So, for each item in $forms
, you want to check if that form_id
matches the form_id
requested in the Shortcode. if there is a match, return
the form_markup
from that item.
If no matches were found, return
an error message.
$forms = get_field( 'forms', 'option' );
foreach ( $forms as $form ) {
if( $atts['form_id'] == $form['form_id'] ){
return $form['form_markup'];
}
}
return 'form id ' . $atts['form_id'] . ' not found';
Related Posts:
- Using ACF field in do_shortcode()
- possibility to control embedded video timeline with buttons and links external to the player
- Problem with using custom shortcode with ACF WYSIWYG field
- Can I wrap an unordered list inside a shortcode?
- Create shortcode in WordPress, using one variable in 3 functions?
- Shortcode default attributes over-riding non-default attributes
- Image Shortcode from ACF ID
- Basic do shortcodes question
- How to Generate html tags using shortcodes?
- Pass fileurl parameter into shortcode from Advanced Custom Fields
- Custom Shortcode + Querying and Ordering Posts using multiple Advanced Custom checkboxes
- Ordering get_terms with ACF not displaying all terms
- Adding a custom field to do_shortcode [closed]
- Shortcode strips formatting and returns at content top
- ACF repeater + group shortcode
- Need help in setting up a transient using API Key and if possible updating it in the ACF field
- Shortcode custom query not passing value
- If statement shortcode
- how to add acf value to other plugins shortcode?
- How do I use “while” and “end while” inside of the echo do_shortcode with ACF Repeater?
- How can I hide the ACF shortcode when empty
- Conditionally Loading JavaScript/CSS for Shortcodes
- Show shortcode without executing it
- How does a shortcode work?
- Run visual composer code in php page
- Remove wptexturize from a shortcode?
- Using shortcode in Post title
- Shortcodes, HTML tables, and multiple rows
- Audio or playlist shortcode condition according to the amount of files on attachment page
- Does a shortcode with a single attribute have to use an array?
- Use [shortcode=”value”] instead of [shortcode att=”value”]?
- Tinymce shortcodes within shortcode contents
- I dont want to show shortcode in tag
- Post loop created via shortcode not displaying shortcode in content
- Pass shortcode variables to template
- passing multiple parents value into a shortcode
- Is it possible to add a repeater field to TinyMCE’s option window?
- Shortcodes: Pros and Cons
- esc_attr not working in shortcode
- Raw output (preventing wpautop)
- Conditionally loading Facebook PHP SDK in shortcode
- Can’t understand $atts in functions?
- Are .MP3 files with capital letter extensions allowed in [audio] shortcode?
- How to handle shortcodes when using the JSON API
- Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?
- is_admin() returns false in save_post hook with Gutenberg editor
- Why are Shortcodes Disabled in Widgets by Default?
- Get Posts shortcode plugin and meta_query?
- WordPress Gallery shortcode: Display one category ID only
- How to get gallery id inserted to a post?
- WordPress Shortcode show database row
- Custom shortcode is not working in text widget
- Having issues with a foreach inside of a shortcode with ACF gallery
- Use shortcodes in terms description? [closed]
- Adding to the_content or a variable from within a shortcode function
- Shortcode: text content ends up outside html tags
- Create a shortcode to use in visual editor
- What is this format called (nested shortcodes)?
- Problem with height in video shortcode
- Shortcode not showing $content in correct place
- Best tools for preparing and styling a table [closed]
- Best way to include reusable sections in page content
- How can I insert a shortcode in the title tag of another?
- Shortcode inside text widget do not call enqueue style
- How to execute a shortcode outside the post content/entry in a theme?
- Metabox Keeps Stripping Parts of Shortcode
- Form processing: How to process form before output and access data from shortcode
- How to Retrieve data of Gallery Shortcode and display it above a post
- Checking post content for a shortcode, but content is being returned as empty
- do_shortcode() won’t return PHP Array
- Adding my own custom woocommerce shortcode to child theme, how?
- contact form 7 :create shortcode usable in email message [closed]
- Better way to display multiple plugin output on the same page?
- get_queried_object_id / short code returning blank
- Shortcode won’t take into account custom post ID put in parameter
- How to utilise multiple values from a single shortcode attribute?
- JavaScript missing from shortcode content
- shortcode to display specific recent posts
- wp_link_pages shortcode for ‘nextpagelink’
- Function in a wordpress shortcode
- nested shortcodes from different plugins. too complex? [duplicate]
- How to display a page dependent on a url parameter supplied by a form/button page?
- Can’t place endwhile in the loop properly in a shortcode
- How to reduce the image size inside an icon? [closed]
- How to insert visual compser post grid shortcode in a custom page template? [closed]
- WordPress plugin shortcodes not outputting anything
- Manipulated shortcode output
- Where is escaped the shortcode?
- Changing layout of defaul gallery output to masonry
- shortcode change variable base on user
- Inserting shortcode is blanking excerpt – any ideas?
- If do_shortcode is blank, return some message
- Previous/Next with the same category
- I’ve broken the short code for Contact Form 7!
- echo a shortcode in a shortcode code?
- How to enable on custom shortcodes
- Nested ShortCode works inside the_content, but not outside of it
- wordpress how to sort posts on custom data with plug-in “Search & Filter”
- How to reuse php templates as shortcodes?
- Shortcode attributes from meta query variables