Home › Forums › General Issues › Displaying acf values in Elementor using HTML › Reply To: Displaying acf values in Elementor using HTML
// Add Shortcode to display ACF field value for the scrolling marquee
function marquee_text_shortcode() {
// Get the ID of the current page being viewed
$post_id = get_the_ID();
// Get the ACF field value for THAT specific page/post
$marquee_text = get_field(‘marquee_txt’, $post_id);
// Check if the field has content and return it
if ( $marquee_text ) {
// We use esc_html() to make sure the output is secure
return esc_html($marquee_text);
}
// Optional: Return a default message if the field is empty
return ‘See calendar for details ✦’;
}
add_shortcode( ‘scroll_txt’, ‘marquee_text_shortcode’ );
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.