How do I pass an ACF value into a shortcode for a different plugin/function?
I’m building out a booking site with need to add a calendar. The calendars reference an ID (number) that is contained in an ACF field.
Shortcode needs to look like this: [bookingcalendar type=“ID”]. I need to be able to dynamically replace ID with the number specified in the custom field of each post.
I wanted to return to this in case anyone else might have had a similar query.
The Dynamic Inserter function solves this rather easily as it turns out.
In my case, all I needed was to insert an ACF into a shortcode. Since Cwicly’s Paragraph block is a bit of a jack-of-all-trades block, it’s all we need.
First, we create the ACF field as needed and grab the slug:
Finally, add the shortcode using a paragraph block and the Dynamic Inserter Function to place the field value in the code.
In my case, the code needed to be [bookingcalendar type={RESOURCEID} nummonths=2]: