Skip to content
Advertisement

Using PHP WordPress variable do_shortcode for dynamic content

I’m building a WordPress site and my aim to have users be able to place custom shortcodes in the backend of WordPress on blog posts and have that content display on the site.

I’m using a simple text field Advanced Custom Field to do this (below.) but am struggling to integrate this with the do_shortcode variable.

Any help would be greatly appreciated, thanks.

video-id

Get Advanced Custom Field input to display as plaintext

JavaScript

Get WordPress to output video

JavaScript

My attempt of combining the two

JavaScript

Advertisement

Answer

In do_shortcode replace the_field with get_field.

the_field is return a value. get_field is print a value.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement