Site logo

Archived topic

Custom fields

18 replies · Started by Kerry on December 11, 2018

Viewing posts 16–19 of 19

That typically means $your_field isn't an array.

Is that error happening on pages where that variable is definitely an array?

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

Hi Dan,

It depends on the output of those custom fields. Any chance you can open a new topic and we'll try to debug them?

Last thing, sorry. It doesn't show when 0 comments. Can get it to say '0 comments' when no comments?

0comments

Thank you again :-)

This archived topic is closed to new replies.