Home › Forums › Front-end Issues › Shortcodes in text field › Reply To: Shortcodes in text field
no, both of these ‘solutions’ are needlessly complex and add_filter might be a potential security risk across every field rather than just the one you want to use
a text field is plain text, therefore it can be directly utilized in php, which is what get_field()
is for, rather than the_field()
that wraps the data into its own echo function
so it’s simply do_shortcode( get_field('FIELDNAME') );
of course the best practice in case there’s no data and if there’s extra html around it is to check if it exists first
if ( get_field('FIELDNAME') ) {
echo do_shortcode( get_field('FIELDNAME') );
}
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.