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"]
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.