Get taxonomy brands

Hello Team!

I think that the new and updated version of the plugin it is really very good work and powerful.

Reading your instructions I made the following template from which I want to draw from a taxonomy-brands the title and the image. With the following I have the title but without an image

<Loop taxonomy=yith_product_brand post=current>
  <Field title />

I would like also the title and the image to be active towards the brand url of “brand taxonomy”.

Any help me is welcome

Thanks in advance

Hey Dennis! I assume you’ve used something like ACF to add an image field to the terms of your yith_product_brand taxonomy? If that’s the case, then you should just be able to use something like <Field name_of_your_image_field /> within that loop you’ve written to display that image.

As far as hyperlinking your image (assuming that’s what you mean by “to be active towards the brand URL”), assuming that brand URL is also a custom field in your taxonomy, you could use the standard HTML <a> tag like this (obviously swapping out the values for the actual ones in use on your site):

<a href="{Field brand_url_field_name}"><Field brand_image_field_name /></a>

Hopefully, that points you in the right direction. Let me know if that works out for you!

Sorry, my omission, I did not mention that this is not from custom fields plugin, but this

Thank you and sorry for the inconvenience.

Ah ok. I’m not really a developer myself and I haven’t used that plugin so I couldn’t tell you exactly how to do what you’re trying to do, but I did find some info here about an easy way to find out what field names are being used by a particular post. Once you know what those field names are, you should be able to swap those into the markup I shared above. Hope that’s helpful!

Unfortunately after several attempts I could not find the right fields.

Anyway, thanks for your time Benjamin!

1 Like

A developer on our team just took a peek at that plugin’s source code and sent me some info that might be helpful for you. It seems like the meta key (the name of the field) that you’d need for the brand image might be called thumbnail_id. You could try just adding a little <Field thumbnail_id /> to your taxonomy term loop and see what that outputs.

Since that field (probably) only contains the image ID and not the image itself, the way to display it would probably be to use that ID to create an attachment loop and then get the image URL within the attachment loop. Might sound complicated but in theory, it should be pretty simple. Something like this:

<Loop taxonomy=yith_product_brand post=current>
  <Loop type=attachment id="{Field thumbnail_id">
    <img src="{Field url}" />

That might get you the image you’re looking for and from there you could wrap the image and title in an <a> tag to get it to link to whatever you’d like. I’m still not sure what you meant by wanting the title and image “to be active towards the brand url of ‘brand taxonomy’” but hopefully this at least helps you move in the right direction!

1 Like

Thank you very much for your time. But we had searched in the source code of the plugin and we had found this information but without any luck after tests. Of course your information is more well structured, but still I do not see it working.

I feel very bad that I have created this inconvenience, I will look for alternatives.

1 Like