How to display ACF taxonomy field in autocomplete?

Wordpress plugin version: 2.11.2

I have an ACF taxonomy field which is pushed to Algolia.
In the Algolia dashboard I see that field and attributes.

rj_klasa_rjesenja:UP/II-034-02/18-01/544
rj_narucitelj:[
{
term_id: “1444”
name: “Industrijski park Nova Gradiška d.o.o.”
etc.:
}
]
rj_broj_objave:2018/S 0F2-0012542

How to display rj_narucitelj.name attribute? The code below doesn’t work. Does this account for an array? Do I need to loop through it? If yes, how?

<span class="rj-narucitelj">{{{data.rj_narucitelj.name}}}</span>

On the other hand when i try to display author name on the same way it does work.

<span class="rj-author">{{{data.post_author.display_name}}}</span>

Also, every single field in that indice can display without problems.

I’ve tried editing the wordpress template, and made a standalone client, but I can’t get it work either way.

What am I missing?

I appreciate the help.

Hi @prodaja,

The value is in an array. You can do either:

  • access a specific “by index” value. For example to get the first one, you can do:
    {{data.rj_narucitelj.0.name}}
  • or you can loop over the values of the array, like so:
    {{#data.rj_narucitelj}}{{name}}{{/rj_narucitelj}}

Well, I’m modifiying autocomplete.php template.

I’ve set them at searchable attributes, and also
attributes to retrieve/snippet/highlight.

The examples are returning an error.

The first error is -> “Uncaught SyntaxError: Unexpected token . at new Function ()”

The second returns -> “Uncaught SyntaxError: Invalid or unexpected token at new Function ()”

Do I need to modify some additional settings?