Skip to main content

Displaying HTML or Iframe with the Dynamic Field Widget

Updated over a year ago

To display HTML or an iframe dynamically using the Dynamic Field widget, follow these steps:

  1. Set Meta Field Type:

    • Ensure the meta field type for your content is set to Textarea. This will allow the field to handle HTML or iframe code.

  2. Disable Widget Sanitization:

    • By default, the Dynamic Field widget sanitizes content, which removes HTML tags. To display HTML or iframe code, you need to disable this sanitization.

      Add the following code to the functions.php file of your child theme or in the Code Snippets plugin. This code will disable sanitization for the Dynamic Field widget: (Visit this link to access the code)

  3. Add the Dynamic Field Widget:

    • Place the Dynamic Field widget where you want the meta field to display.

    • In the widget settings, make sure to add the class disable-sanitize to allow the HTML or iframe code to render without being stripped.

  4. Test the Output:

    • The HTML or iframe should now display correctly. This approach also works well for standard HTML content in the Dynamic Field widget.

Did this answer your question?