Sorry to hijack the thread, I have created a shortcode to call a ACF custom field I created:
add_shortcode( 'hero_title', function() {
$term = get_queried_object();
$hero_title = get_field( 'hero-title', $term );
return $hero_title;
} );
add_shortcode( 'hero_subtitle', function() {
$term = get_queried_object();
$hero_subtitle = get_field( 'hero-subtitle', $term );
return $hero_subtitle;
} );
The ACF field is: hero-title
In the header element I have:
<div class="inner-hero-text">
<h2>[hero_title]
</h2>
<h3>[hero_subtitle]
</h3>
</div>
The only output I see is:
<div class="inner-hero-text">
<h2>Blog
</h2>
<h3>
</h3>
</div>
Any thoughts why it’s not pulling in the custom fields and only outputtng “Blog”?
Thanks
Dan