Home / Admin / Display Shortcodes Inside HTML Fields
Duplicate Snippet

Embed Snippet on Your Site

Display Shortcodes Inside HTML Fields

Allows shortcodes to be processed within HTML fields by applying do_shortcode() to the field content.

300+
Code Preview
php
<?php
/**
 * Run shortcodes on HTML field content
 *
 * @link   https://wpforms.com/developers/how-to-display-shortcodes-inside-the-html-field/
 * 
 * For support, please visit: https://www.facebook.com/groups/wpformsvip
 */
function wpf_dev_html_field_shortcodes( $field, $field_atts, $form_data ) {
 
    if ( ! empty( $field[ 'code' ] ) ) {
        $field[ 'code' ] = do_shortcode( $field[ 'code' ] );
    }
 
    return $field;
}
add_filter( 'wpforms_html_field_display', 'wpf_dev_html_field_shortcodes', 10, 3 );

Comments

Add a Comment