[Resolved] Custom fields

Home Forums Support [Resolved] Custom fields

Home Forums Support Custom fields

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #960361
    Tom
    Lead Developer
    Lead Developer

    That typically means $your_field isn’t an array.

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

    #1295725
    Dan

    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

    #1296001
    Tom
    Lead Developer
    Lead Developer

    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?

    #1672517
    Simon

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

    0comments

    Thank you again 🙂

Viewing 4 posts - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.