Support

Account

Home Forums Backend Issues (wp-admin) Cannot return get_field() in translated language for terms

Unread

Cannot return get_field() in translated language for terms

  • I am trying to return the url of an icon (implemented with ACF + WPML) from a translated custom taxonomy term:

    @php
    $terms = get_terms(array(
    'taxonomy' => 'parcours',
    'hide_empty' => true,
    ));
    @endphp
    
    @if (!empty($terms))
    @foreach ($terms as $term)
    @php
    $id = $term->term_id;
    $taxonomy = $term->taxonomy;
    $slug = $term->slug;
    $name = $term->name;
    $image = get_field('route_icon', $taxonomy . '_' . $id);
    @endphp
    
    @php echo $image @endphp
    
    @endforeach
    @endif

    No matter what i have tried (wpml_object_id included). The image variable is empty in the translated site only. The variable is returning the expedted data in the original language and everything is working well. Also the id variable is returning the correct translated id as expected.

    Am I doing something wrong in ACF? Thanks a lot for your help.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.