Support

Account

Home Forums Feature Requests Wrap fields' textarea in div (for styling/positioning) Reply To: Wrap fields' textarea in div (for styling/positioning)

  • Came up with a solution in the meantime… Just requires adding a few lines to your theme’s functions.php file:

    
    function greenbg_shortcode($params, $content = null) {
    	extract(shortcode_atts(array(
    		'field' => ''
    	), $params));
    
    	if($field != '') {
    		return '<div class="full-width green-bg">'.get_field($field).'</div>';
    	} else {
    		return null;
    	}
    }
    add_shortcode('greenbg','greenbg_shortcode');
    

    It uses the same syntax as the default ACF shortcode (so you’ll still need to specify the field=”field_name” part), like so:

    [greenbg field="green-bg-copy"]